帮忙将php函数转成go方法?

imcdn · · 2026 次点击
``` func encrypt(input string, key string) string { block, _ := des.NewTripleDESCipher([]byte(key)) blockSize := block.BlockSize() input = pkcs7Pad(input, blockSize) ciphertext := make([]byte, len(input)) mode := cipher.NewCBCEncrypter(block, make([]byte, blockSize)) mode.CryptBlocks(ciphertext, []byte(input)) return strings.ToUpper(hex.EncodeToString(ciphertext)) } func pkcs7Pad(input string, blockSize int) string { padSize := blockSize - len(input)%blockSize pad := strings.Repeat(string(byte(padSize)), padSize) return input + pad } ```
#4
更多评论
万能百度(其实我也不懂)
#1
des-ecb加密,有别人写好的包
#2