SimpleCrypto.net
SimpleCrypto.net copied to clipboard
buggy salt to byte array conversion
hi, i attempted to use SimpleCrypto.NET to generate hashes that are used on another platform (node) and found number of discrepancies (known password and salt should produce same results across platforms assuming that same digest algorithm and key size is used).
- salt is prefixed with number of iterations which makes sense however the [xxxx.] prefix should not be used - explanation below....
- salt string to byte conversion is performed using Encoding.UTF8.GetBytes(Salt) which is not the correct way of decoding base64 string (compare with new Buffer(salt, 'base64') in JS). Convert.FromBase64String should be used instead, but you'd need to split the number of iterations from actual base64 salt to do so.
I'd also add support for hex string input / output as well. would you consider a pull request?
hi, i attempted to use SimpleCrypto.NET to generate hashes that are used on another platform (node) and found number of discrepancies (known password and salt should produce same results across platforms assuming that same digest algorithm and key size is used).
- salt is prefixed with number of iterations which makes sense however the [xxxx.] prefix should not be used - explanation below....
- salt string to byte conversion is performed using Encoding.UTF8.GetBytes(Salt) which is not the correct way of decoding base64 string (compare with new Buffer(salt, 'base64') in JS). Convert.FromBase64String should be used instead, but you'd need to split the number of iterations from actual base64 salt to do so.
I'd also add support for hex string input / output as well. would you consider a pull request?
Would you by any chance have a fork with the needed fixes?