-
Notifications
You must be signed in to change notification settings - Fork 0
/
pass-entropy.scm
30 lines (26 loc) · 1 KB
/
pass-entropy.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
(import (srfi 48))
(define (characters-pool capitals numbers specials)
(let loop ((pool 26)
(capitals capitals)
(numbers numbers)
(specials specials))
(cond
(capitals
(loop (* pool 2) #f numbers specials))
(numbers
(loop (+ pool 10) capitals #f specials))
(specials
(loop (+ pool 10) capitals numbers #f))
(else pool))))
;; Based on https://www.pleacher.com/mp/mlessons/algebra/entropy.html
(define (calc-password-entropy pass char-pool)
(log (expt char-pool (string-length pass)) 2))
(define (pretty-entropy-format entropy)
(define entropy-grade
(cond
((< entropy 28) "Garbage.")
((and (> entropy 29) (< entropy 35)) "Weak, Don't use it.")
((and (> entropy 36) (< entropy 59)) "Okeyish, but not recommended.")
((and (> entropy 60) (< entropy 127)) "Strong, You can use it.")
((> entropy 128) "Very Strong, This one is the best!")))
(format "The password entropy is ~2,2F bits which is ~a~%" entropy entropy-grade))