neotam
neotam

Reputation: 2731

I am getting wrong result in python when I trying to compare the two strings in python

Why I am getting wrong result when I compare the two strings .

if password==en_pass:
            log.info("##### client credentials are OK ####")
else:
     print "credentials are wrong "

i am getting the result which is in else block

Here is the my log message:

got the password :bmF2ZWVu  , encoded password :bmF2ZWVu

where encoded password is from base64 , that is i got that by using encodestring method in base 64 module.

Upvotes: 0

Views: 1720

Answers (1)

gefei
gefei

Reputation: 19856

it seems that password is not 'bmF2ZWVu', but contains trailing spaces, like 'bmF2ZWVu '. Try if password.strip()==en_pass.strip()

Upvotes: 6

Related Questions