Coder Social home page Coder Social logo

cryptsharp's Introduction

Hello there ๐Ÿ‘‹

cryptsharp's People

Contributors

chrismckee avatar paragonie-scott avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cryptsharp's Issues

SCrypt salt issue

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.

Needs update to 2.0

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).

Vocabulary question

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.