Handbook
Glossary
passwd-md5 ( magic salt password -- bytes )
MD5 shadow passwords
Next:
parse-shadow-password ( string -- magic salt password )
Vocabulary
crypto
.
passwd-md5
Inputs
magic
a
string
salt
a
string
password
a
string
Outputs
bytes
an md5-shadowed password entry
Word description
Encodes the password with the given magic string and salt to an MD5-shadow password entry.
Definition
USING:
checksums
checksums.md5
combinators
crypto.passwd-md5.private
grouping
kernel
math
math.bits
math.functions
sequences
;
IN:
crypto.passwd-md5
::
passwd-md5
( magic salt password -- bytes )
password magic salt
3append
salt password
1surround
md5
checksum-bytes
password
length
[
16
/
ceiling
swap
<repetition>
concat
]
keep
head-slice
append
password
[
length
make-bits
]
[
first
]
bi
[
[
0
]
]
dip
[
?
]
curry
compose
""
map-as
append
md5
checksum-bytes
:>
final! 1000
<iota>
[
""
swap
{
[
0
bit?
password final
?
append
]
[
3
mod
0
>
[
salt
append
]
when
]
[
7
mod
0
>
[
password
append
]
when
]
[
0
bit?
final password
?
append
]
}
cleave
md5
checksum-bytes
final!
]
each
magic salt
"$"
3append
{
12 0 6 13 1 7 14 2 8 15 3 9 5 4 10
}
final
nths
3
group
[
first3
[
16
shift
]
[
8
shift
]
bi*
+
+
4
to64
]
map
concat
11 final
nth
2
to64
3append
;