mirror of
https://github.com/charlienet/go-mixed.git
synced 2025-07-18 00:22:41 +08:00
加密包装
This commit is contained in:
15
crypto/padding.go
Normal file
15
crypto/padding.go
Normal 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)]
|
||||
}
|
Reference in New Issue
Block a user