chrismckee / cryptsharp Goto Github PK
View Code? Open in Web Editor NEWGIT Clone of the source files in http://www.zer7.com/software.php?page=cryptsharp
License: Other
GIT Clone of the source files in http://www.zer7.com/software.php?page=cryptsharp
License: Other
I found an issue with SCrypt that will cause it to generate the same hash every time with different salts.
First I generated a random string of characters from the full character set (char)0 - (char)65535.
private static string NewSalt()
{
var salt = string.Empty;
var random = new Random();
for (var i = 0; i < 16; i++)
{
salt += (char)random.Next(Char.MinValue, Char.MaxValue);
}
return salt;
}
In almost all cases my salts contain characters with high character values. When I use this to hash passwords the hashes end up being the same with different salts.
private static string SaltAndHashPassword(string password, string salt)
{
const int len = 64;
const int parallel = 16;
const int blockSize = 8;
const int cost = 1024;
var derivedBytes = new byte[len];
SCrypt.ComputeKey(Encoding.ASCII.GetBytes(password), Encoding.ASCII.GetBytes(salt), cost, blockSize, parallel, null, derivedBytes);
return new string(HexBase16.Encode(derivedBytes));
}
Is there something I am doing wrong or does the SCrypt algorithm not allow for characters over a certain range? When I limit the salt to (char)0 - (char)255 it works every time.
I find myself needing to reverse engineer this a little bit as I can't find a public function that allows me to validate an entered password against a known hash.
The official CryptSharp page already has 2.0 (well, for more than a year). It would be nice to update this repository with the current version of the source code (or visibly mark it obsolete, or whatever).
Are you encrypting the passwords or are you hashing them? Because when the API says 'test the crypted password against a potential password' I feel like running around in circles yelling about cats.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.