mirror of
https://github.com/arnaucube/blockchainIDsystem.git
synced 2026-02-07 11:06:41 +01:00
started to implement clientApp (Go + Electron(with Angularjs))
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
"math/rand"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -181,3 +182,28 @@ func PubKStringToBigInt(kS RSAPublicKeyString) (RSAPublicKey, error) {
|
||||
}
|
||||
return k, nil
|
||||
}
|
||||
|
||||
type PackRSA struct {
|
||||
PubK string `json:"pubK"`
|
||||
PrivK string `json:"privK"`
|
||||
}
|
||||
|
||||
func PackKey(k RSA) PackRSA {
|
||||
var p PackRSA
|
||||
p.PubK = k.PubK.E.String() + "," + k.PubK.N.String()
|
||||
p.PrivK = k.PrivK.D.String() + "," + k.PrivK.N.String()
|
||||
return p
|
||||
}
|
||||
|
||||
func UnpackKey(p PackRSA) RSA {
|
||||
var k RSA
|
||||
var ok bool
|
||||
k.PubK.E, ok = new(big.Int).SetString(strings.Split(p.PubK, ",")[0], 10)
|
||||
k.PubK.N, ok = new(big.Int).SetString(strings.Split(p.PubK, ",")[1], 10)
|
||||
k.PrivK.D, ok = new(big.Int).SetString(strings.Split(p.PrivK, ",")[0], 10)
|
||||
k.PrivK.N, ok = new(big.Int).SetString(strings.Split(p.PrivK, ",")[1], 10)
|
||||
if !ok {
|
||||
fmt.Println("error on Unpacking Keys")
|
||||
}
|
||||
return k
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user