PBKDF2 hashing for Bash
Go to file
Ze'ev Schurmann 2647fc16cd Update 'README.md' 2024-01-05 02:24:26 +02:00
LICENSE Initial commit 2024-01-05 01:33:33 +02:00
README.md Update 'README.md' 2024-01-05 02:24:26 +02:00
pbkdf2.sh Removed the commented out variables used in early testing. 2024-01-05 02:08:27 +02:00

README.md

pbkdf2

PBKDF2 hashing for Bash

USAGE

$ bash pbkdf2.sh hashtype salt password iterations {raw/full/rawfull}

or

$ ./pbkdf2.sh hashtype salt password iterations {raw/full/rawfull}

hashtype string

Options: md5, sha1, sha224, sha256, sha384, sha512, blake2b, blake2s, sha3_224, sha3_256, sha3_384, sha3_512, shake_128, shake_256

salt string

This must be a predefind string of A-Z, a-z and 0-9.

password string

The password you want hashed.

iterations integer

Range 1 to 2147483647. The higher the integer the more secure but at the cost of time.

{raw/full/rawfull} optional

This is optional. By default you will get a hash string followed by a new line. If you do not want the new line, say to use in a variable, then use 'raw' to get just the hash in hex. However if you use 'full', you will get a string that can be used to input into a database with a new line at the end. Use 'rawfull' to return the string without the new line.

What is PBKDF2?

PBKDF2 applies a pseudorandom function, such as hash-based message authentication code (HMAC), to the input password or passphrase along with a salt value and repeats the process many times to produce a derived key, which can then be used as a cryptographic key in subsequent operations. The added computational work makes password cracking much more difficult, and is known as key stretching. Source: Wikipedia

PBKDF2 is used in many applications where a password needs to be stored for future verification. Unlike just using a straight Hashing Algorithm, PBKDF2 uses a "salt" along side the password, and rehashes repeatedly according to the number of "iterations".

Why did I write this script?

I needed to be able to write passwords to MySQL/MariaDB/SQLite databases from the commandline. I couldn't find a native way to create the hash, and doing it in pure Bash took forever, so I eventually found a way to do it quickly by embedding Python code in the script.

NOTE:

This script requires Python3 which as it's own license. Please visit https://github.com/python/cpython for more information.

DONATIONS

Please consider making me small donation. Even though my scripts are open source and free to use, I still need to eat. And the occasional bottle of wine also goes down well.

  • $5 buys me a cup of coffee
  • $10 buys me a nice burger
  • $20 buys me a bottle of wine
  • Anything above that will be awesome as well.

You can send me a donation via Paypal https://www.paypal.com/paypalme/thisiszeev

Drop me a message on Reddit if you do make a donation. u/thisiszeev

Support is only offered freely to those who donate $20 or more.

Your donation contributes to further development.

If you need a custom script, contact me on Reddit for pricing.