public function encrypt($input,$key){
$size = mcrypt_get_block_size (MCRYPT_3DES, MCRYPT_MODE_ECB );
$input = $this->pkcs7_pad($input, $size);
$key = base64_decode($key);
$td = @mcrypt_module_open(MCRYPT_3DES, '', MCRYPT_MODE_ECB, '');
@mcrypt_generic_init($td, $key,'');
$data = mcrypt_generic($td, $input);
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
return strtoupper(bin2hex($data));
}
```
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