本文整理汇总了Python中BitVector.__getslice__方法的典型用法代码示例。如果您正苦于以下问题:Python BitVector.__getslice__方法的具体用法?Python BitVector.__getslice__怎么用?Python BitVector.__getslice__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitVector
的用法示例。
在下文中一共展示了BitVector.__getslice__方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: aesDecryption
# 需要导入模块: import BitVector [as 别名]
# 或者: from BitVector import __getslice__ [as 别名]
def aesDecryption(cipherfile,roundkeys,np):
print ("Decryption begin %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
f = open(cipherfile,'r')
hexstr = f.read()
print (hexstr)
m = 0
n = 32
strlis = []
while(n <= len(hexstr)):
strlis.append(hexstr[m:n])
m += 32
n += 32
packages = BitVector(size=0)
print ("substr AAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAa")
print (strlis)
for substr in strlis:
package = BitVector(hexstring=substr)
print (package.get_hex_string_from_bitvector())
last4w = BitVector(size = 0)
for j in range(len(roundkeys[10])):
last4w += roundkeys[10][j]
print ("last4w")
print (last4w.get_hex_string_from_bitvector())
packager = package ^ last4w
print ("packager")
print (packager.get_hex_string_from_bitvector())
for ri in range(9,-1,-1):
print (str(ri)+" Decrypt round$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$")
shiftrows = inv_shift_rows(packager)
subinv = inv_sub_bytes(shiftrows)
print ("subinv")
print (subinv.get_hex_string_from_bitvector())
ad_rk = add_round_key(subinv,roundkeys,ri)
print ("ad_rk")
print (ad_rk.get_hex_string_from_bitvector())
if ri > 0:
colum_inv = inv_mix_columns(ad_rk)
else:
colum_inv = ad_rk
packager = colum_inv
print ("packager")
print (packager.get_hex_string_from_bitvector())
packages += packager
for i in range(9,0,-1):
print (i)
print ("np")
print (np)
if np > 0:
packages = packages.__getslice__(0,(len(strlis)-1)*128+np)
print (packages.get_hex_string_from_bitvector())
outfile = "decryptedtext.txt"
fo = open(outfile,'w')
packages.write_to_file(fo)
hh = "abcdefghijklmn"
print (hh)
rr = hh[0:5]
print (rr)