keypair err mgt + shorturl random improve

This commit is contained in:
ycc
2026-02-02 15:11:41 +01:00
parent f8537aad6d
commit f498cfad1e
23 changed files with 778 additions and 1052 deletions

View File

@@ -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 {