keypair err mgt + shorturl random improve
This commit is contained in:
@@ -42,13 +42,19 @@ WE88AQOdxtE8dAuu16suOpgLUfluDgnzCg==
|
||||
-----END PGP PUBLIC KEY BLOCK-----`
|
||||
|
||||
func TestNewKeyPair(t *testing.T) {
|
||||
kp := NewKeyPair()
|
||||
kp, err := NewKeyPair()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
fmt.Println(kp.Public)
|
||||
fmt.Println(kp.Private)
|
||||
}
|
||||
|
||||
func TestGetKey(t *testing.T) {
|
||||
kp := NewKeyPair()
|
||||
kp, err := NewKeyPair()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// fmt.Println(kp.Public)
|
||||
// fmt.Println(kp.Private)
|
||||
key := kp.GetCryptoKeyObject()
|
||||
@@ -65,7 +71,10 @@ func TestGetKey(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAsymEncryptDecrypt(t *testing.T) {
|
||||
kp := NewKeyPair()
|
||||
kp, err := NewKeyPair()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
foo := []byte("!#$%&()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~")
|
||||
encMess, err := AsymEncrypt(kp.Public, foo)
|
||||
if err != nil {
|
||||
@@ -80,7 +89,10 @@ func TestAsymEncryptDecrypt(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAsymEncryptDecryptSigned(t *testing.T) {
|
||||
kp := NewKeyPair()
|
||||
kp, err := NewKeyPair()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
foo := "!#$%&()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~"
|
||||
enc, err := AsymEncryptAndSign(kp.Public, kp.Private, []byte(foo))
|
||||
if err != nil {
|
||||
@@ -94,7 +106,10 @@ func TestAsymEncryptDecryptSigned(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAsymEncryptDecryptSigned2(t *testing.T) {
|
||||
kp := NewKeyPair()
|
||||
kp, err := NewKeyPair()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
foo := "!#$%&()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~"
|
||||
enc, err := AsymEncryptAndSign(kp.Public, kp.Private, []byte(foo))
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user