0
구성 파일에 저장된 암호화 된 암호 (기본 64 + AES 인코딩)를 읽으려고합니다. 제한된 라이브러리를 사용해야하므로, 내가 찾은 많은 암호화 방법을 시도 할 수 없습니다.구성 파일에서 1 바이트 읽기 python
내가 사용하고있는 코드는
def encrypt_password(): # for encryption
from Crypto.Cipher import AES
obj = AES.new('This is a key123', AES.MODE_CFB, 'This is an IV456')
message = "password$1"
ciphertext = obj.encrypt(message) #ciphertext is the encrypted password
내가 암호 해독에 대한 구성 파일
에 enc_password으로 암호문을 배치하고있다
def decrypt_password():
from Crypto.Cipher import AES
cipher_text=RPF.readfromConfigFile('LoginCredentials','enc_password')
obj2 = AES.new('This is a key123', AES.MODE_CFB, 'This is an IV456')
message = obj2.decrypt(cipher_text)
message = message.decode("utf-8") #gives the decrypted password
내가 직면하고 문제는 읽는 동안이다 구성 파일에서 암호화 된 암호는 문자열로 읽히지 만 바이트는되어야합니다 (필자가 믿는다). 내가 구성 파일에서 읽어 방법이 있습니다 :
if moduleName == 'LoginCredentials':
import io
config.read('configuration.INI')
list_of_variables = [config.get('LoginCredentials', 'url'), config.get('LoginCredentials', 'UserName'),
config.get('LoginCredentials', 'enc_password')]
너희들이 솔루션을 제공 할 수 있기를 바랍니다 .. `
어떤 오류 메시지가 나타 납니까? – everyone
오류는 UnicodeDecodeError입니다 : 'utf-8'코덱은 위치 2에서 바이트 0xb0을 디코딩 할 수 없습니다. 유효하지 않은 시작 바이트 –
디버거를 사용하여 디코딩하기 전에 디버거를 사용하여'message' 값을 확인하십시오. – everyone