client.py 文件源码

python
阅读 76 收藏 0 点赞 0 评论 0

项目:Networking 作者: JoaoChervinski 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号