GithubHelp home page GithubHelp logo

juil / scrypt Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pbhogan/scrypt

1.0 2.0 0.0 95 KB

A Ruby gem with native C extension for the scrypt password hashing algorithm.

Home Page: https://github.com/pbhogan/scrypt

License: Other

scrypt's Introduction

= scrypt

The scrypt key derivation function is designed to be far more secure against hardware brute-force attacks than alternative functions such as PBKDF2 or bcrypt.

* http://www.tarsnap.com/scrypt.html
* http://github.com/pbhogan/scrypt

== Why you should use scrypt

The designers of scrypt estimate that on modern (2009) hardware, if 5 seconds are spent computing a derived key, the cost of a hardware brute-force attack against scrypt is roughly 4000 times greater than the cost of a similar attack against bcrypt (to find the same password), and 20000 times greater than a similar attack against PBKDF2.

== How to install scrypt

  gem install scrypt

== How to use scrypt

It works pretty similarly to ruby-bcrypt with a few minor differences, especially where the cost factor is concerned.

	include "scrypt"

	# hash a user's password
	@password = Password.create("my grand secret")
	@password #=> "2000$8$1$f5f2fa5fe5484a7091f1299768fbe92b5a7fbc77$6a385f22c54d92c314b71a4fd5ef33967c93d679"

	# store it safely
	@user.update_attribute(:password, @password)

	# read it back
	@user.reload!
	@db_password = Password.new(@user.password)

	# compare it after retrieval
	@db_password == "my grand secret" #=> true
	@db_password == "a paltry guess"  #=> false

Password.create takes three options which will determine the cost limits of the computation.
* :max_time specifies the maximum number of seconds the computation should take.
* :max_mem specifies the maximum number of bytes the computation should take. A value of 0 specifies no upper limit. The minimum is always 1 MB.
* :max_memfrac specifies the maximum memory in a fraction of available resources to use. Any value equal to 0 or greater than 0.5 will result in 0.5 being used.

Default options will result in calculation time of approx. 200 ms with 1 MB memory use.

scrypt's People

Contributors

bhaak avatar freaky avatar pbhogan avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.