fix(aes-encryption): support plain txt and url safe base64 strings

Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
This commit is contained in:
ivan katliarchuk 2024-12-28 15:38:37 +00:00
parent e964a66153
commit ad226caeb9
No known key found for this signature in database
GPG Key ID: 601CDBBBB76E47BE

View File

@ -78,15 +78,26 @@ import (
) )
func main() { func main() {
key := []byte("testtesttesttesttesttesttesttest") keys := []string{
"ZPitL0NGVQBZbTD6DwXJzD8RiStSazzYXQsdUowLURY=", // safe base64 url encoded 44 bytes and 32 when decoded
"01234567890123456789012345678901", // plain txt 32 bytes
"passphrasewhichneedstobe32bytes!", // plain txt 32 bytes
}
for _, k := range keys {
key := []byte(k)
encrypted, _ := endpoint.EncryptText( encrypted, _ := endpoint.EncryptText(
"heritage=external-dns,external-dns/owner=example,external-dns/resource=ingress/default/example", "heritage=external-dns,external-dns/owner=example,external-dns/resource=ingress/default/example",
key, key,
nil, nil,
) )
decrypted, _, _ := endpoint.DecryptText(encrypted, key) decrypted, _, err := endpoint.DecryptText(encrypted, key)
if err != nil {
fmt.Println("Error decrypting:", err, "for key:", k)
}
fmt.Println(decrypted) fmt.Println(decrypted)
} }
}
``` ```
## Caching ## Caching