19 lines
461 B
Go
19 lines
461 B
Go
|
package security
|
||
|
|
||
|
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)
|
||
|
}
|