Giter VIP home page Giter VIP logo

cl-diceware's Introduction

cl-diceware

This is a Common Lisp implementation of the Diceware passphrase generation algorithm.

You can find a description of the algorithm at http://diceware.com

MIT license in LICENSE, and at the bottom of source files.

It's a lot more effort to get cryptographically secure random numbers in Windows, so I didn't bother.

Pretty standard lisp package. System definition in cl-diceware.asd.

Tested in Clozure Common Lisp (CCL) and Steel Bank Common Lisp (SBCL).

Command-line script

The "diceware" file is a bash script to print passphrases in a shell.

;; Run in CCL (assuming "ccl" will start the lisp).
./diceware [<count>]

;; Run in SBCL
LISP=sbcl ./diceware [<count>]

;; Run in other lisp
LISP=whatever LISP_OPTIONS="--noprint options" ./diceware [<count>]

<count> defaults to 5. Non-integer , e.g. "-h" or "--help", prints help.

;; Use /dev/random instead of the default of /dev/urandom
;; (Or set CL_DICEWARE_REAL_RANDOM=t in your shell init file)
CL_DICEWARE_REAL_RANDOM=t ./diceware [<count>]

Function reference

All functions and variables below are exported from the cl-diceware package. Random bytes are fetched from /dev/random, except on Windows, where it uses cl:random.

with-/dev/random (&optional stream) &body body

A macro to bind an (unsigned-byte 8) stream to STREAM around the execution of BODY. Wrap calls to the RANDOM-xxx functions with this to prevent multiple opening and closing of /dev/random.

random-byte

Returns a random integer between 0 and 255 (inclusive).

random-integer limit

Returns a random integer >= 0 and < limit. Same as cl:random, but better randomness.

random-word

Returns a random word from the Diceware word list.

random-words count

Returns a list of COUNT random words from the Diceware word list.

random-words-string count

Returns a string containing COUNT random words, separated by spaces.

*real-random-p*

Variable controls whether to use /dev/random or /dev/urandom for random numbers. If true and not :USE-FEATURES, will use /dev/random, otherwise /dev/urandom. If EQ to :USE-FEATURES, will use /dev/random only if :CL-DICEWARE-REAL-RANDOM-P is in *FEATURES*. cl-diceware.asd pushes :CL-DICEWARE-REAL-RANDOM-P onto *FEATURES* if the CL_DICEWARE_REAL_RANDOM environment variable is non-blank.

Default: use /dev/urandom

Bill St. Clair <[email protected]>
4 September 2015

cl-diceware's People

Contributors

billstclair avatar

Stargazers

Józef Piątkiewicz avatar Lau avatar Jon Atack avatar

Watchers

 avatar James Cloos avatar Jon Atack 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.