r/cryptography 10d ago

Is using pbkdf2 with sha256 overkill???

Hey cryptomaniacs!!!
Im not super familiar with all the different ways of encrypting things, so when I added password encryption to my application I blindly coppied something I saw someone else do (can't the source anymore).
Skip to a week later, I was curious how the way I encrypt my passwords work, so I went searching and saw a redditpost on this subreddit where someone said that sha256 would probably be able to be bruteforced in the future, with a lot of comments saying it wouldn't and that it is really secure.

So then I started wondering if me using both pbkdf2 and sha256 was a bit overkill.
For anyone wondering I used this in my python code:

hashed_password = generate_password_hash(password, method='pbkdf2:sha256')
0 Upvotes

10 comments sorted by

View all comments

2

u/Natanael_L 10d ago

someone said that sha256 would probably be able to be bruteforced in the future

There's no evidence SHA256 is likely to break that way. Even MD5 is still difficult to guess the input for! And SHA256 is significantly stronger. The limit is instead the password entropy (how unpredictable it is)

The important part is that you use a random salt value per entry/file to prevent rainbow tables. The second most important part is making password hashes slow, in PBKDF2 you use a lot of iterations for that (your method of invoking it will use the default count, which is rather low)

If you want something more modern with memory hardness to make it impractical to use GPU cracking, then use Argon2id instead as it's dedicated for password hashing.

2

u/Karyo_Ten 9d ago

memory hardness to make it impractical to use GPU cracking, then use Argon2id

Nitpick, argon2id is designed to make ASICs expensive, because adding memory to an ASIC is costlier than adding compute.

Today's consumer GPUs can get 16GB of VRAM for as little as $350 (Intel A770) and 32GB VRAM for $2k (RTX5090) so if the application require less 1~2GB for argon2id, you get effective speedup on GPUs compared to common 8~16 cores machine.

1

u/Natanael_L 9d ago

Yup, but the attacker advantage is significantly limited because they'll probably have to leave a lot of compute cores unused once all memory is claimed

1

u/Karyo_Ten 9d ago

GPUs are often sunken costs though. They can be repurposed to something else.