sonarqube-badges/security/aes/aes.go

19 lines
456 B
Go
Raw Permalink Normal View History

2025-03-15 01:49:52 +01:00
package aes
2025-03-13 08:25:39 +01:00
import (
"crypto/sha256"
goaes "github.com/syronz/goAES"
)
func EncryptAES(password string, plaintext string) string {
iv := sha256.Sum256([]byte(password))
aes, _ := goaes.New().Key(password).IV(string(iv[:16])).Build()
return aes.Encrypt(plaintext)
}
func DecryptAES(password string, ct string) string {
iv := sha256.Sum256([]byte(password))
aes, _ := goaes.New().Key(password).IV(string(iv[:16])).Build()
return aes.Decrypt(ct)
}