Skip to content

JS Implementation of SCrypt wrapped in a module for node.js consumption.

License

Notifications You must be signed in to change notification settings

tracker1/node-js-scrypt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-js-scrypt

JS Implementation of SCrypt wrapped in a module for node.js consumption. There are no compiled dependencies for this module. It returned the computed bytes as a Buffer, not the Scrypt Hash Format (c2NyeXB0) string with included metadata.

Installation

npm install js-scrypt

Usage

var scrypt = require('js-scrypt');

//asynchronous
scrypt.hash(password, salt [,options], callback);

//synchronous
var resultBuffer = scrypt.hashSync(password, salt [,options])

Parameters

  • password (String or Buffer) - the value to be encoded/
    • String will be encoded to bytes as UTF-8.
    • Buffer will be encoded as-is.
  • salt (String or Buffer) - random data to be included in the hash.
    • String will be encoded to bytes as UTF-8.
    • Buffer will be encoded as-is.
  • options (Object, optional)
    • maxmem (Integer, optional) - the total memory available for scrypt in megabytes
      • default: 32
      • allowed values are (4,8,16,32,64,128,256,512,1024,2048)
    • cost (Integer, optional) - (N) must be a power of two, will set the overall difficulty of the computation.
      • default: 16384 - Math.pow(2,14)
      • min: Math.pow(2,8) - 256
      • max: Math.pow(2,64) - 18446744073709552000
      • Math.pow(2,14) - the scrypt paper's suggestion for interactive logins
      • Math.pow(2,20) - the scrypt paper's suggestion for filesystem encryption
    • blockSize (Integer, optional) - (r) blocksize to use
      • default: 8
      • min: 1
      • max: 256
    • parallel (Integer, optional) - (p) parallelization factor
      • default: 1 (given the runtime environment, it is probably best to leave this as-is)
      • min: 1
      • max: 256
    • size (Integer, optional) - (L) length of result (number of bytes to generate)
      • default: 64 (this is a 512bit result, which is plenty for general password usage)
      • min: 1
      • max: 2048
  • callback (Function) - function(err, resultBuffer)

TODO

  • Create method(s) to simulate time/memory computation of Nrp vectors which will return a c2NyeXB0 Scrypt Hash Format string.

License

node-js-scrypt is written by Michael J. Ryan [email protected] and is licensed under the 2-clause BSD license:

Copyright © 2013, Michael J. Ryan
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

node-js-scrypt relies on js-scrypt which is written by Tony Garnock-Jones [email protected] and is licensed under the 2-clause BSD license:

Copyright © 2013, Tony Garnock-Jones
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

js-scrypt relies on scrypt itself, which is written by Colin Percival and licensed as follows:

Copyright 2009 Colin Percival
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

About

JS Implementation of SCrypt wrapped in a module for node.js consumption.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •