0

So I am busy with a program that takes multiple encoded AES encrypted values from a table and decrypts those values once the value is decrypted it is supposed to check if the input is the same as the decrypted value and from what I am seeing it is but the program still ends up with false here is the code:

username = "AMY"
password = "Aims!@#$%^&*("
print(username)
print(password)
for row in result:
    cdata = row[1]
    C2 = AES.new(key, AES.MODE_CBC, iv)
    plainname = unpad(C2.decrypt(cdata), 16)
    data = row[2]
    C3 = AES.new(key, AES.MODE_CBC, iv)
    plainpass= unpad(C3.decrypt(data),16)

    print(plainname.decode())
    name = plainname.decode()
    if (name == username):
        print("true")

the output is:

AMY
Aims!@#$%^&*(
YASU
KASI
JAMES
JASON
JJ
AMY
YASEEN

the first value is the text input the second last value is the value from the table which it should be compared to it should say true when it gets to this value but it is not. My only guesses are either the types are somehow different or maybe I left a space in the database or something like that.

New contributor
Yaseen Latiff is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
2
  • Try print(repr(plainname.decode())) so you can see spaces.
    – Barmar
    1 hour ago
  • 'Y\x00A\x00S\x00U\x00' 'K\x00A\x00S\x00I\x00' 'J\x00A\x00M\x00E\x00S\x00' 'J\x00A\x00S\x00O\x00N\x00' 'J\x00J\x00' 'A\x00M\x00Y\x00' 'Y\x00A\x00S\x00E\x00E\x00N\x00' This is what I get. This means that there are no spaces at the end. 1 hour ago

0

Your Answer

Yaseen Latiff is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.