Skip to content
This repository has been archived by the owner on Apr 4, 2018. It is now read-only.

Commit

Permalink
Add README.
Browse files Browse the repository at this point in the history
  • Loading branch information
threedaymonk committed Jan 17, 2012
1 parent 3b32768 commit 420ab69
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
PassphraseEntropy
=================

Estimate the entropy of a passphrase. This is calculated as the number of bytes
required to encode the passphrase on top of a Deflate stream of a preset
dictionary.

Inspired by [xkcd 936](http://xkcd.com/936/).

Usage
-----

require "passphrase_entropy"

pe = PassphraseEntropy.new
# or customise the dictionary:
pe = PassphraseEntropy.new(File.read("/usr/share/dict/words"))

pe.entropy("password") # => 6
pe.entropy("correct horse battery staple") # => 24
pe.entropy("Tr0ub4dor&3") # => 21

You can decide on your acceptable level of complexity.

Notes
-----

It's a bit slow: the dictionary must be deflated every time. This could be
ameliorated by saving the state, but that would require a modified zlib
library. (It's easy to do with a pure Ruby zlib library, but Ruby is so much
slower in this case that the overall gain in speed is almost zero.))

0 comments on commit 420ab69

Please sign in to comment.