defuse/password-hashing — pull request #1 by redbeard0x0a (2013-10-09 01:11:50+00:00)
Title: Compatibility fix for Ruby

I grabbed the code from https://crackstation.net/hashing-security.htm today because I needed a PBKDF2 password hash that gets generated with Java and can have a password checked from a Ruby and a C# app. I missed the fact that the Java code encoded the salt and hash using hexadecimal and the C# and Ruby code used Base64. Even after updating the Java code to use Base64, the Ruby code still wasn't working with the Java or C# hashes.

The Ruby implementation had a bug with how the salt was generated and used when generating the hash (it was using a string instead of byte array). This caused it to validate within the ruby implementation, but the resulting hash wouldn't validate in the C# implementation (or the Java implementation if you switch out hex encoding with Base64 encoding). I also added the slow equals method with example code from the ruby documentation for OpenSSL::PKCS5.

I also added a Main method to the C# code, ported from the Java code.