package security import ( "confrontation-training/constant" "encoding/base64" "github.com/forgoer/openssl" ) func Encrypt(src string) string { encrypt, _ := openssl.Des3CBCEncrypt([]byte(src), []byte(constant.DefaultKey), []byte(constant.DefaultIv), openssl.PKCS5_PADDING) return base64.StdEncoding.EncodeToString(encrypt) } func Decrypt(src string) string { decodeString, err := base64.StdEncoding.DecodeString(src) if err != nil { return "" } decrypt, err := openssl.Des3CBCDecrypt(decodeString, []byte(constant.DefaultKey), []byte(constant.DefaultIv), openssl.PKCS5_PADDING) return string(decrypt) }