@@ -26,7 +26,7 @@ func AesEncrypt(key, text []byte) ([]byte, error) {
26
26
ciphertext := make ([]byte , aes .BlockSize + len (b ))
27
27
iv := ciphertext [:aes .BlockSize ]
28
28
if _ , err = io .ReadFull (rand .Reader , iv ); err != nil {
29
- return nil , fmt .Errorf ("AesEncrypt unable to read iv : %w" , err )
29
+ return nil , fmt .Errorf ("AesEncrypt unable to read IV : %w" , err )
30
30
}
31
31
cfb := cipher .NewCFBEncrypter (block , iv )
32
32
cfb .XORKeyStream (ciphertext [aes .BlockSize :], []byte (b ))
@@ -48,7 +48,7 @@ func AesDecrypt(key, text []byte) ([]byte, error) {
48
48
cfb .XORKeyStream (text , text )
49
49
data , err := base64 .StdEncoding .DecodeString (string (text ))
50
50
if err != nil {
51
- return nil , fmt .Errorf ("AesDecrypt invalid decrtyped base64 string: %w" , err )
51
+ return nil , fmt .Errorf ("AesDecrypt invalid decrypted base64 string: %w" , err )
52
52
}
53
53
return data , nil
54
54
}
@@ -69,11 +69,11 @@ func DecryptSecret(key, cipherHex string) (string, error) {
69
69
keyHash := sha256 .Sum256 ([]byte (key ))
70
70
ciphertext , err := hex .DecodeString (cipherHex )
71
71
if err != nil {
72
- return "" , fmt .Errorf ("failed to decrtyp by secret, invalid hex string: %w" , err )
72
+ return "" , fmt .Errorf ("failed to decrypt by secret, invalid hex string: %w" , err )
73
73
}
74
74
plaintext , err := AesDecrypt (keyHash [:], ciphertext )
75
75
if err != nil {
76
- return "" , fmt .Errorf ("failed to decrtyp by secret, secret key (SECRET_KEY) might be incorrect: %w" , err )
76
+ return "" , fmt .Errorf ("failed to decrypt by secret, secret key (SECRET_KEY) might be incorrect: %w" , err )
77
77
}
78
78
return string (plaintext ), nil
79
79
}
0 commit comments