|
@@ -66,6 +66,14 @@ func SHA256(origin string, salt string) string {
|
|
|
return fmt.Sprintf("%x", sha256.Sum256([]byte(origin)))
|
|
return fmt.Sprintf("%x", sha256.Sum256([]byte(origin)))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func Base64Encode(content []byte) string {
|
|
|
|
|
+ return base64.StdEncoding.EncodeToString(content)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func Base64Decode(content string) ([]byte, error) {
|
|
|
|
|
+ return base64.StdEncoding.DecodeString(content)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
func pkcs7Padding(ciphertext []byte, blockSize int) []byte {
|
|
func pkcs7Padding(ciphertext []byte, blockSize int) []byte {
|
|
|
padding := blockSize - len(ciphertext)%blockSize
|
|
padding := blockSize - len(ciphertext)%blockSize
|
|
|
padText := bytes.Repeat([]byte{byte(padding)}, padding)
|
|
padText := bytes.Repeat([]byte{byte(padding)}, padding)
|