Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int rounds = Int32.Parse(salt.Substring(offset, 2), NumberFormatInfo.InvariantInfo);
- byte[] passwordBytes = Encoding.UTF8.GetBytes(password + (minor >= 'a' ? "\0" : String.Empty));
- byte[] saltBytes = DecodeBase64(salt.Substring(offset + 3, 22),
- BCRYPT_SALT_LEN);
- BCrypt bcrypt = new BCrypt();
- byte[] hashed = bcrypt.CryptRaw(passwordBytes, saltBytes, rounds);
- StringBuilder rs = new StringBuilder();
- rs.Append("$2");
- if (minor >= 'a') {
- rs.Append(minor);
- }
- rs.Append('$');
- if (rounds < 10) {
- rs.Append('0');
- }
- rs.Append(rounds);
- rs.Append('$');
- rs.Append(EncodeBase64(saltBytes, saltBytes.Length));
- rs.Append(EncodeBase64(hashed,
- (bf_crypt_ciphertext.Length * 4) - 1));
- return rs.ToString();
Advertisement
Add Comment
Please, Sign In to add comment