문제

I do want to verify a Django framework generated hash with the PassLib library (https://pythonhosted.org/passlib/lib/passlib.hash.django_std.html)

My python script looks like that:

#!/usr/bin/python2.7

import sys
from passlib.hash import django_pbkdf2_sha256 as handler

def verifizieren(password_plain, django_hash):
     handler.verify(password_plain, django_hash)

def main():
    print (sys.argv[1])
    print (sys.argv[2])
    verifizieren(sys.argv[1], sys.argv[2])

main()

When I call my script in the command line with

python myscript.py test pbkdf2_sha256$12000$EkKZXYXv0adl$GZppRyXed3a0y1uZMBR/F8Mu/rnpsN+7atY4hZAwlrQ=

Somehow, my hash is cutted. Instead of

pbkdf2_sha256$12000$EkKZXYXv0adl$GZppRyXed3a0y1uZMBR/F8Mu/rnpsN+7atY4hZAwlrQ=

my argv[2] is

pbkdf2_sha2562000/F8Mu/rnpsN+7atY4hZAwlrQ=

Why is python cutting away the rest of my command line parameter? And how can I avoid this?

도움이 되었습니까?

해결책

try to call your script as follows:

python myscript.py test 'pbkdf2_sha256$12000$EkKZXYXv0adl$GZppRyXed3a0y1uZMBR/F8Mu/rnpsN+7atY4hZAwlrQ='

the single quotes around the second argument will protect the string from being interpreted by the shell, as the shell understands anything that follows a $ as a shell variable.

As $EkKZXYXv0adl and $GZppRyXed3a0y1uZMBR obviously do not exist in your shell environment, they expand to nothing.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top