def encrypt():
ciphertext = ''
with open(args.filename, 'r') as arq:
content = arq.readlines()
for index in range(len(content)):
content[index] = content[index].rstrip('\n')
try:
for line in content:
for index in range(len(line)):
bin_text = format(int(line[index]), '#06b')
bin_secret = format(int(args.secret[index]), '#06b')
for item in range(len(bin_text)):
if item < 2:
ciphertext += bin_text[item]
else:
ciphertext += str(xor(int(bin_text[item]), int(bin_secret[item])))
except IndexError:
print '[*] WARNING: The key and the text must be of the same size.'
quit()
return ciphertext
评论列表
文章目录