Code Monkey home page Code Monkey logo

python-pbkdf2's People

Contributors

dlitz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-pbkdf2's Issues

crypt() uses unexpected salt value

I think users expect crypt("hi", "mom", iterations=1) to return the hash value as the 192-bit PBKDF2 result for PBKDF2("hi", "mom", iterations=1) but it does not.
Instead, the actual salt value used in crypt("hi", "mom", iterations=1) is not "mom" but is rather the value "$p5k2$1$mom".

b64encode(PBKDF2("hi", "mom", iterations=1).read(24),"./")
'dRUSa0XKUkjbqg5NOyaNy9t4F1fXTQ6T'

crypt("hi", "mom", iterations=1)
'$p5k2$1$mom$7e7fV91gTM4ceXPmLUMU45GSLvyPc2Vt'

b64encode(PBKDF2("hi", "**$p5k2$1$**mom", iterations=1).read(24),"./")
'7e7fV91gTM4ceXPmLUMU45GSLvyPc2Vt'

patch starting at line 276 sends only the salt to PBKDF2() rather than the salt plus all the decoration that comes before it:

    if iterations is None or iterations == 400:
        iterations = 400
#        salt = "$p5k2$$" + salt
        rc = "$p5k2$$" + salt
    else:
#        salt = "$p5k2$%x$%s" % (iterations, salt)
        rc = "$p5k2$%x$%s" % (iterations, salt)
    rawhash = PBKDF2(word, salt, iterations).read(24)
#    return salt + "$" + b64encode(rawhash, "./")
    return rc + "$" + b64encode(rawhash, "./")

after patching you see the returned hash is the expected value:

crypt("hi", "mom", iterations=1)
'$p5k2$1$mom$dRUSa0XKUkjbqg5NOyaNy9t4F1fXTQ6T'

Allowed chars in SALT - [space]

I need to use space char (" ") in the 'salt' parameter (PBKDF2.crypt()) to generate a PBKDF2 key for an specific purpose. On my machine, I've already changed this code (line #271) and the tests has finished with status OK.

The line 271 became like that (space is the last char):
allowed = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./ "

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.