1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 00:22:41 +08:00

加密包装

This commit is contained in:
2022-03-27 10:21:30 +08:00
parent 22f41aeeeb
commit 12865abe26
14 changed files with 1068 additions and 0 deletions

15
crypto/padding.go Normal file
View File

@ -0,0 +1,15 @@
package crypto
import "bytes"
func PKCS7Padding(src []byte, blockSize int) []byte {
padding := blockSize - len(src)%blockSize
padtext := bytes.Repeat([]byte{byte(padding)}, padding)
return append(src, padtext...)
}
func PKCS7UnPadding(src []byte) []byte {
length := len(src)
unpadding := int(src[length-1])
return src[:(length - unpadding)]
}