如何在Python中将b'IV = 2D2C077194150102B3B3B3B3B3B3B3B3B3'转换为格式b'-,\ x07q \ x94 \ x15 \ x01 \ x02 \ xb3 \ xb3 \ xb3 \ xb3 \ xb3 \ xb3 \ xb3 \ xb3 \ xb3'

问题描述

我正在使用python3中的Crypto.Cipher模块在AES CBC 128模式下工作, 在aes cbc128中,IV必须为16字节,格式为“ x07q \ x94 \ x15 \ x01 \ x0 ........”,

我该如何转型 来自

(select ZIP,count(*) from tab37 group by ZIP order by count(*) desc limit 10)
union all
(select ZIP,count(*) from tab38 group by ZIP order by count(*) desc limit 10)
union all
(select ZIP,count(*) from tab39 group by ZIP order by count(*) desc limit 10)
union all
(select ZIP,count(*) from tab40 group by ZIP order by count(*) desc limit 10)

TO

b'IV= 2D2C077194150102B3B3B3B3B3B3B3B3' 

我尝试在Google中搜索b“ xxx” = python中的字节字符串吗? 我尝试了函数to_bytes,bytearray没有成功。 谢谢

解决方法

好。我自己解决....但是我的问题不完全

b'IV = 2D2C077194150102B3B3B3B3B3B3B3B3B3' 它是一个字节字符串。 我需要做什么 1)是将其更改为字符串 2)删除IV = 3)删除“ =”之后的前导空格 代码添加为

new_product.save!

感谢您提供帮助的人