【发布时间】:2019-01-27 11:02:53
【问题描述】:
I've found this exactly same question。但是 PyCrypto 不会同时安装在 python 3.6.5 和 3.7.0 上。
所以,我实现了某种类似于 Gronsfeld 的密码。我知道,这很糟糕,但我可以简单地用密码加密和解密字符串
def encrypt(string, password):
int_list = []
password_len = len(password)
for cnt, sym in enumerate(string):
password_sym = password[cnt % password_len]
int_list.append(ord(sym)-ord(password_sym))
return int_list
# got some list which contain mine key to Todoist api, yes, this can be bruteforced, but same as any other API key
>>> [-20, -20, -50, -14, -61, -54, 2, 0, 32, 27, -51, -21, -54, -53, 4, 3, 29, -14, -51, 29, -10, -6, 1, 4, 28,
29, -55, -17, -59, -42, 2, 50, -13, -14, -52, -15, -56, -59, -44, 4]
def decrypt(int_list, password):
output_string = ""
password_len = len(password)
for cnt, numb in enumerate(int_list):
password_sym = password[cnt % password_len]
output_string += chr(numb+ord(password_sym))
return output_string
那么,应该怎么做呢?
【问题讨论】:
-
我测试了你的代码,它可以工作。你到底有什么问题?
-
您尝试安装 PyCrypto 了吗?它在 3.6 上运行良好。
-
@Sharku 我认为它不安全:/
-
@DanielRoseman `Command ""c:\program files (x86)\python36-32\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\ \EEgorov.NWX\\AppData\\Local\\Temp\\pip-install-6hs9ukdo\\pycrypto\\setup.py';f=getattr(tokenize, 'open', open)(文件);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec' ))" install --record C:\Users\EEgorov.NWX\AppData\Local\Temp\pip-record-m0z81zyx\install-record.txt --single-version-externally-managed --compile" 失败,错误代码1 在 C:\Users\EEgorov.NWX\AppData\Local\Temp\pip-install-6hs9ukdo\pycrypto`
标签: python python-3.x security