栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

在Golang中解密在Python AES CFB中加密的内容

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

在Golang中解密在Python AES CFB中加密的内容

尝试像这样从Python加密。

然后可以从Go成功解密结果。

 #!/usr/bin/env python3import base64from Crypto.Cipher import AESMODE = AES.MODE_CFBBLOCK_SIZE = 16SEGMENT_SIZE = 128def _pad_string(value):    length = len(value)    pad_size = BLOCK_SIZE - (length % BLOCK_SIZE)    return value.ljust(length + pad_size, 'x00')def encrypt(key, iv, plaintext):    aes = AES.new(key, MODE, iv, segment_size=SEGMENT_SIZE)    plaintext = _pad_string(plaintext)    encrypted_text = aes.encrypt(plaintext)    return encrypted_textkey = 'TfvY7I358yospfWKcoviZizOShpm5hyH'iv = 'mb13KcoviZizvYhp'original_message = 'This is not encrypted'encryptedpayload = base64.b64enpre(encrypt(key, iv, original_message))print('Going to encrypt and base64 "{}" result:n{}n'.format(original_message,encryptedpayload))

来源:http://chase-seibert.github.io/blog/2016/01/29/cryptojs-pycrypto-
ios-aes256.html



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/413146.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号