https://github.com/billstclair/cl-diceware
Diceware passphrase generator in Common Lisp
https://github.com/billstclair/cl-diceware
Last synced: 4 months ago
JSON representation
Diceware passphrase generator in Common Lisp
- Host: GitHub
- URL: https://github.com/billstclair/cl-diceware
- Owner: billstclair
- License: mit
- Created: 2015-09-04T12:12:57.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2022-03-26T07:49:52.000Z (about 4 years ago)
- Last Synced: 2026-01-20T10:52:52.684Z (5 months ago)
- Language: Common Lisp
- Size: 238 KB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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 []`
;; Run in SBCL
`LISP=sbcl ./diceware []`
;; Run in other lisp
`LISP=whatever LISP_OPTIONS="--noprint options" ./diceware []`
<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 []`
## 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 <billstclair@gmail.com>
4 September 2015