add more tests for codec (#391)

This commit is contained in:
Kevin Wan
2021-01-14 23:39:44 +08:00
committed by GitHub
parent 50fbdbcfd7
commit 6887fb22de
2 changed files with 71 additions and 7 deletions

View File

@@ -146,15 +146,15 @@ func EcbEncryptBase64(key, src string) (string, error) {
}
func getKeyBytes(key string) ([]byte, error) {
if len(key) > 32 {
if keyBytes, err := base64.StdEncoding.DecodeString(key); err != nil {
return nil, err
} else {
return keyBytes, nil
}
if len(key) <= 32 {
return []byte(key), nil
}
return []byte(key), nil
if keyBytes, err := base64.StdEncoding.DecodeString(key); err != nil {
return nil, err
} else {
return keyBytes, nil
}
}
func pkcs5Padding(ciphertext []byte, blockSize int) []byte {