<s>
crypt	B-Algorithm
is	O
a	O
POSIX	B-Language
C	I-Language
library	I-Language
function	O
.	O
</s>
<s>
It	O
is	O
typically	O
used	O
to	O
compute	O
the	O
hash	B-Algorithm
of	O
user	O
account	O
passwords	O
.	O
</s>
<s>
The	O
function	O
outputs	O
a	O
text	O
string	O
which	O
also	O
encodes	O
the	O
salt	O
(	O
usually	O
the	O
first	O
two	O
characters	O
are	O
the	O
salt	O
itself	O
and	O
the	O
rest	O
is	O
the	O
hashed	O
result	O
)	O
,	O
and	O
identifies	O
the	O
hash	B-Algorithm
algorithm	O
used	O
(	O
defaulting	O
to	O
the	O
"	O
traditional	O
"	O
one	O
explained	O
below	O
)	O
.	O
</s>
<s>
More	O
formally	O
,	O
crypt	B-Algorithm
provides	O
cryptographic	O
key	B-Algorithm
derivation	I-Algorithm
functions	I-Algorithm
for	O
password	O
validation	O
and	O
storage	O
on	O
Unix	O
systems	O
.	O
</s>
<s>
There	O
is	O
an	O
unrelated	O
crypt	B-Algorithm
utility	O
in	O
Unix	O
,	O
which	O
is	O
often	O
confused	O
with	O
the	O
C	O
library	O
function	O
.	O
</s>
<s>
To	O
distinguish	O
between	O
the	O
two	O
,	O
writers	O
often	O
refer	O
to	O
the	O
utility	O
program	O
as	O
crypt(1 )	O
,	O
because	O
it	O
is	O
documented	O
in	O
section	O
1	O
of	O
the	O
Unix	B-Protocol
manual	I-Protocol
pages	O
,	O
and	O
refer	O
to	O
the	O
C	O
library	O
function	O
as	O
crypt(3 )	O
,	O
because	O
its	O
documentation	O
is	O
in	O
manual	O
section	O
3	O
.	O
</s>
<s>
This	O
same	O
crypt	B-Algorithm
function	O
is	O
used	O
both	O
to	O
generate	O
a	O
new	O
hash	B-Algorithm
for	O
storage	O
and	O
also	O
to	O
hash	B-Algorithm
a	O
proffered	O
password	O
with	O
a	O
recorded	O
salt	O
for	O
comparison	O
.	O
</s>
<s>
Modern	O
Unix	O
implementations	O
of	O
the	O
crypt	B-Algorithm
library	O
routine	O
support	O
a	O
variety	O
of	O
hash	B-Algorithm
schemes	O
.	O
</s>
<s>
The	O
particular	O
hash	B-Algorithm
algorithm	O
used	O
can	O
be	O
identified	O
by	O
a	O
unique	O
code	O
prefix	O
in	O
the	O
resulting	O
hashtext	O
,	O
following	O
a	O
de	O
facto	O
standard	O
called	O
Modular	O
Crypt	B-Algorithm
Format	O
.	O
</s>
<s>
The	O
crypt( )	O
library	O
function	O
is	O
also	O
included	O
in	O
the	O
Perl	B-Language
,	O
PHP	B-Application
,	O
Pike	O
,	O
Python	B-Language
(	O
although	O
it	O
is	O
now	O
deprecated	O
as	O
of	O
3.11	O
)	O
,	O
and	O
Ruby	B-Language
programming	I-Language
languages	I-Language
.	O
</s>
<s>
To	O
enable	O
backward	B-General_Concept
compatibility	I-General_Concept
,	O
each	O
scheme	O
started	O
using	O
some	O
convention	O
of	O
serializing	B-Application
the	O
password	B-Algorithm
hashes	I-Algorithm
that	O
was	O
later	O
called	O
the	O
Modular	O
Crypt	B-Algorithm
Format	O
(	O
MCF	O
)	O
.	O
</s>
<s>
Old	O
crypt(3 )	O
hashes	B-Algorithm
generated	O
before	O
the	O
de	O
facto	O
MCF	O
standard	O
may	O
vary	O
from	O
scheme	O
to	O
scheme	O
.	O
</s>
<s>
A	O
well-defined	O
subset	O
of	O
the	O
Modular	O
Crypt	B-Algorithm
Format	O
was	O
created	O
during	O
the	O
Password	O
Hashing	O
Competition	O
.	O
</s>
<s>
id	O
:	O
an	O
identifier	O
representing	O
the	O
hashing	O
algorithm	O
(	O
such	O
as	O
1	O
for	O
MD5	B-Algorithm
,	O
5	O
for	O
SHA-256	B-Algorithm
etc	O
.	O
)	O
</s>
<s>
The	O
PHC	O
subset	O
covers	O
a	O
majority	O
of	O
MCF	O
hashes	B-Algorithm
.	O
</s>
<s>
The	O
original	O
implementation	O
of	O
the	O
crypt( )	O
library	O
function	O
in	O
Third	O
Edition	O
Unix	O
mimicked	O
the	O
M-209	O
cipher	O
machine	O
.	O
</s>
<s>
In	O
Seventh	B-Operating_System
Edition	I-Operating_System
Unix	I-Operating_System
,	O
the	O
scheme	O
was	O
changed	O
to	O
a	O
modified	O
form	O
of	O
the	O
DES	B-Algorithm
algorithm	O
.	O
</s>
<s>
In	O
detail	O
,	O
the	O
user	O
's	O
password	O
is	O
truncated	O
to	O
eight	O
characters	O
,	O
and	O
those	O
are	O
coerced	O
down	O
to	O
only	O
7-bits	O
each	O
;	O
this	O
forms	O
the	O
56-bit	O
DES	B-Algorithm
key	O
.	O
</s>
<s>
That	O
key	O
is	O
then	O
used	O
to	O
encrypt	O
an	O
all-bits-zero	O
block	O
,	O
and	O
then	O
the	O
ciphertext	O
is	O
encrypted	O
again	O
with	O
the	O
same	O
key	O
,	O
and	O
so	O
on	O
for	O
a	O
total	O
of	O
25	O
DES	B-Algorithm
encryptions	O
.	O
</s>
<s>
A	O
12-bit	O
salt	O
is	O
used	O
to	O
perturb	O
the	O
encryption	O
algorithm	O
,	O
so	O
standard	O
DES	B-Algorithm
implementations	O
ca	O
n't	O
be	O
used	O
to	O
implement	O
crypt( )	O
.	O
</s>
<s>
The	O
salt	O
and	O
the	O
final	O
ciphertext	O
are	O
encoded	O
into	O
a	O
printable	O
string	O
in	O
a	O
form	O
of	O
base64	B-Protocol
.	O
</s>
<s>
However	O
,	O
one	O
of	O
the	O
properties	O
of	O
DES	B-Algorithm
is	O
that	O
it	O
's	O
very	O
resistant	O
to	O
key	O
recovery	O
even	O
in	O
the	O
face	O
of	O
known	O
plaintext	O
situations	O
.	O
</s>
<s>
It	O
is	O
theoretically	O
possible	O
that	O
two	O
different	O
passwords	O
could	O
result	O
in	O
exactly	O
the	O
same	O
hash	B-Algorithm
.	O
</s>
<s>
The	O
traditional	O
DES-based	O
crypt	B-Algorithm
algorithm	O
was	O
originally	O
chosen	O
because	O
DES	B-Algorithm
was	O
resistant	O
to	O
key	O
recovery	O
even	O
in	O
the	O
face	O
of	O
"	O
known	O
plaintext	O
"	O
attacks	O
,	O
and	O
because	O
it	O
was	O
computationally	O
expensive	O
.	O
</s>
<s>
On	O
the	O
earliest	O
Unix	O
machines	O
it	O
took	O
over	O
a	O
full	O
second	O
to	O
compute	O
a	O
password	B-Algorithm
hash	I-Algorithm
.	O
</s>
<s>
At	O
that	O
time	O
password	B-Algorithm
hashes	I-Algorithm
were	O
commonly	O
stored	O
in	O
an	O
account	O
file	O
(	O
/etc/passwd	O
)	O
which	O
was	O
readable	O
to	O
anyone	O
on	O
the	O
system	O
.	O
</s>
<s>
This	O
has	O
long	O
since	O
left	O
the	O
DES-based	O
algorithm	O
vulnerable	O
to	O
dictionary	O
attacks	O
,	O
and	O
Unix	O
and	O
Unix-like	O
systems	O
such	O
as	O
Linux	B-Application
have	O
used	O
"	O
shadow	O
"	O
files	O
for	O
a	O
long	O
time	O
,	O
migrating	O
just	O
the	O
password	B-Algorithm
hash	I-Algorithm
values	O
out	O
of	O
the	O
account	O
file	O
(	O
/etc/passwd	O
)	O
and	O
into	O
a	O
file	O
(	O
conventionally	O
named	O
/etc/shadow	O
)	O
which	O
can	O
only	O
be	O
read	O
by	O
privileged	O
processes	O
.	O
</s>
<s>
This	O
had	O
the	O
side	O
effect	O
of	O
making	O
their	O
crypt( )	O
incompatible	O
with	O
the	O
standard	O
crypt( )	O
:	O
the	O
hashes	B-Algorithm
had	O
the	O
same	O
textual	O
form	O
,	O
but	O
were	O
now	O
calculated	O
using	O
a	O
different	O
algorithm	O
.	O
</s>
<s>
This	O
did	O
not	O
increase	O
the	O
cost	O
of	O
hashing	O
,	O
but	O
meant	O
that	O
precomputed	O
hash	B-Algorithm
dictionaries	O
based	O
on	O
the	O
standard	O
could	O
not	O
be	O
applied	O
.	O
</s>
<s>
BSDi	O
used	O
a	O
slight	O
modification	O
of	O
the	O
classic	O
DES-based	O
scheme	O
.	O
</s>
<s>
The	O
chosen	O
number	O
of	O
rounds	O
is	O
encoded	O
in	O
the	O
stored	O
password	B-Algorithm
hash	I-Algorithm
,	O
avoiding	O
the	O
incompatibility	O
that	O
occurred	O
when	O
sites	O
modified	O
the	O
number	O
of	O
rounds	O
used	O
by	O
the	O
original	O
scheme	O
.	O
</s>
<s>
These	O
hashes	B-Algorithm
are	O
identified	O
by	O
starting	O
with	O
an	O
underscore	O
( _	O
)	O
,	O
which	O
is	O
followed	O
by	O
4	O
characters	O
representing	O
the	O
number	O
of	O
rounds	O
then	O
4	O
characters	O
for	O
the	O
salt	O
.	O
</s>
<s>
The	O
BSDi	O
algorithm	O
also	O
supports	O
longer	O
passwords	O
,	O
using	O
DES	B-Algorithm
to	O
fold	O
the	O
initial	O
long	O
password	O
down	O
to	O
the	O
eight	O
7-bit	O
bytes	O
supported	O
by	O
the	O
original	O
algorithm	O
.	O
</s>
<s>
Poul-Henning	O
Kamp	O
designed	O
a	O
baroque	O
and	O
(	O
at	O
the	O
time	O
)	O
computationally	O
expensive	O
algorithm	O
based	O
on	O
the	O
MD5	B-Algorithm
message	B-Algorithm
digest	I-Algorithm
algorithm	O
.	O
</s>
<s>
MD5	B-Algorithm
itself	O
would	O
provide	O
good	O
cryptographic	O
strength	O
for	O
the	O
password	B-Algorithm
hash	I-Algorithm
,	O
but	O
it	O
is	O
designed	O
to	O
be	O
quite	O
quick	O
to	O
calculate	O
relative	O
to	O
the	O
strength	O
it	O
provides	O
.	O
</s>
<s>
The	O
crypt( )	O
scheme	O
is	O
designed	O
to	O
be	O
expensive	O
to	O
calculate	O
,	O
to	O
slow	O
down	O
dictionary	O
attacks	O
.	O
</s>
<s>
The	O
printable	O
form	O
of	O
MD5	B-Algorithm
password	B-Algorithm
hashes	I-Algorithm
starts	O
with	O
$1$	O
.	O
</s>
<s>
First	O
the	O
passphrase	O
and	O
salt	O
are	O
hashed	O
together	O
,	O
yielding	O
an	O
MD5	B-Algorithm
message	B-Algorithm
digest	I-Algorithm
.	O
</s>
<s>
The	O
output	O
of	O
the	O
last	O
of	O
these	O
rounds	O
is	O
the	O
resulting	O
passphrase	O
hash	B-Algorithm
.	O
</s>
<s>
Niels	O
Provos	O
and	O
David	O
Mazières	O
designed	O
a	O
crypt( )	O
scheme	O
called	O
bcrypt	B-Algorithm
based	O
on	O
Blowfish	B-Algorithm
,	O
and	O
presented	O
it	O
at	O
USENIX	B-Operating_System
in	O
1999	O
.	O
</s>
<s>
The	O
printable	O
form	O
of	O
these	O
hashes	B-Algorithm
starts	O
with	O
$2$	O
,	O
$2a$	O
,	O
$2b$	O
,	O
$2x$	O
or	O
$2y$	O
depending	O
on	O
which	O
variant	O
of	O
the	O
algorithm	O
is	O
used	O
:	O
</s>
<s>
Since	O
a	O
major	O
security	O
flaw	O
was	O
discovered	O
in	O
2011	O
in	O
a	O
non-OpenBSD	O
implementation	O
of	O
the	O
algorithm	O
,	O
hashes	B-Algorithm
indicated	O
by	O
this	O
string	O
are	O
now	O
ambiguous	O
and	O
might	O
have	O
been	O
generated	O
by	O
the	O
flawed	O
implementation	O
,	O
or	O
a	O
subsequent	O
fixed	O
,	O
implementation	O
.	O
</s>
<s>
By	O
design	O
,	O
long	O
passwords	O
are	O
truncated	O
at	O
72	O
characters	O
,	O
but	O
there	O
is	O
a	O
byte	O
integer	O
wraparound	O
problem	O
with	O
certain	O
password	O
lengths	O
resulting	O
in	O
weak	O
hashes	B-Algorithm
.	O
</s>
<s>
Old	O
hashes	B-Algorithm
can	O
be	O
renamed	O
to	O
be	O
$2x$	O
to	O
indicate	O
that	O
they	O
were	O
generated	O
with	O
the	O
broken	O
algorithm	O
.	O
</s>
<s>
These	O
hashes	B-Algorithm
are	O
still	O
weak	O
,	O
but	O
at	O
least	O
it	O
's	O
clear	O
which	O
algorithm	O
was	O
used	O
to	O
generate	O
them	O
.	O
</s>
<s>
Blowfish	B-Algorithm
is	O
notable	O
among	O
block	O
ciphers	O
for	O
its	O
expensive	O
key	O
setup	O
phase	O
.	O
</s>
<s>
It	O
proceeds	O
in	O
this	O
fashion	O
,	O
using	O
a	O
progressively	O
modified	O
state	O
to	O
hash	B-Algorithm
the	O
key	O
and	O
replace	O
bits	O
of	O
state	O
,	O
until	O
all	O
subkeys	O
have	O
been	O
set	O
.	O
</s>
<s>
The	O
number	O
is	O
encoded	O
in	O
the	O
textual	O
hash	B-Algorithm
,	O
e.g.	O
</s>
<s>
FreeBSD	O
implemented	O
support	O
for	O
the	O
NT	O
LAN	O
Manager	O
hash	B-Algorithm
algorithm	O
to	O
provide	O
easier	O
compatibility	O
with	O
NT	O
accounts	O
via	O
MS-CHAP	B-Algorithm
.	O
</s>
<s>
The	O
NT-Hash	O
algorithm	O
is	O
known	O
to	O
be	O
weak	O
,	O
as	O
it	O
uses	O
the	O
deprecated	O
md4	B-Algorithm
hash	I-Algorithm
algorithm	O
without	O
any	O
salting	O
.	O
</s>
<s>
The	O
commonly	O
used	O
MD5	B-Algorithm
based	O
scheme	O
has	O
become	O
easier	O
to	O
attack	O
as	O
computer	O
power	O
has	O
increased	O
.	O
</s>
<s>
Although	O
the	O
Blowfish-based	O
system	O
has	O
the	O
option	O
of	O
adding	O
rounds	O
and	O
thus	O
remain	O
a	O
challenging	O
password	O
algorithm	O
,	O
it	O
does	O
not	O
use	O
a	O
NIST-approved	O
algorithm	O
.	O
</s>
<s>
In	O
light	O
of	O
these	O
facts	O
,	O
Ulrich	O
Drepper	O
of	O
Red	O
Hat	O
led	O
an	O
effort	O
to	O
create	O
a	O
scheme	O
based	O
on	O
the	O
SHA-2	B-Algorithm
(	O
SHA-256	B-Algorithm
and	O
SHA-512	B-Algorithm
)	O
hash	B-Algorithm
functions	I-Algorithm
.	O
</s>
<s>
The	O
printable	O
form	O
of	O
these	O
hashes	B-Algorithm
starts	O
with	O
$5$	O
(	O
for	O
SHA-256	B-Algorithm
)	O
or	O
$6$	O
(	O
for	O
SHA-512	B-Algorithm
)	O
depending	O
on	O
which	O
SHA	O
variant	O
is	O
used	O
.	O
</s>
<s>
Its	O
design	O
is	O
similar	O
to	O
the	O
MD5-based	O
crypt	B-Algorithm
,	O
with	O
a	O
few	O
notable	O
differences	O
:	O
</s>
<s>
The	O
MD5	B-Algorithm
algorithm	O
would	O
repeatedly	O
add	O
the	O
first	O
letter	O
of	O
the	O
password	O
;	O
this	O
step	O
was	O
changed	O
significantly	O
.	O
</s>
<s>
yescrypt	O
is	O
an	O
extension	O
of	O
scrypt	B-Algorithm
(	O
)	O
and	O
a	O
PHC	O
finalist	O
.	O
</s>
<s>
It	O
is	O
used	O
in	O
several	O
Linux	B-Application
distributions	I-Application
as	O
an	O
alternative	O
to	O
the	O
existing	O
schemes	O
.	O
</s>
<s>
To	O
use	O
this	O
hash	B-Algorithm
,	O
the	O
from	O
glibc	B-Language
is	O
replaced	O
with	O
a	O
backward-compatible	B-General_Concept
one	O
from	O
the	O
"	O
libxcrypt	O
"	O
project	O
.	O
</s>
<s>
These	O
are	O
PHC-assigned	O
names	O
for	O
the	O
Argon2	B-Algorithm
algorithm	O
,	O
but	O
do	O
not	O
seem	O
to	O
be	O
widely	O
used	O
.	O
</s>
<s>
Additional	O
formats	O
,	O
if	O
any	O
,	O
are	O
described	O
in	O
the	O
man	B-Protocol
pages	I-Protocol
of	O
implementations	O
.	O
</s>
<s>
BigCrypt	O
is	O
the	O
modified	O
version	O
of	O
DES-Crypt	O
used	O
on	O
HP-UX	O
,	O
Digital	O
Unix	O
,	O
and	O
OSF/1	O
.	O
</s>
<s>
The	O
main	O
difference	O
between	O
it	O
and	O
DES	B-Algorithm
is	O
that	O
BigCrypt	O
uses	O
all	O
the	O
characters	O
of	O
a	O
password	O
,	O
not	O
just	O
the	O
first	O
8	O
,	O
and	O
has	O
a	O
variable	O
length	O
hash	B-Algorithm
.	O
</s>
<s>
Crypt16	O
is	O
the	O
minor	O
modification	O
of	O
DES	B-Algorithm
,	O
which	O
allows	O
passwords	O
of	O
up	O
to	O
16	O
characters	O
.	O
</s>
<s>
The	O
GNU	B-Language
C	I-Language
Library	I-Language
used	O
by	O
almost	O
all	O
Linux	B-Application
distributions	I-Application
provides	O
an	O
implementation	O
of	O
the	O
crypt	B-Algorithm
function	O
which	O
supports	O
the	O
DES	B-Algorithm
,	O
MD5	B-Algorithm
,	O
and	O
(	O
since	O
version	O
2.7	O
)	O
SHA-2	B-Algorithm
based	O
hashing	O
algorithms	O
mentioned	O
above	O
.	O
</s>
<s>
Ulrich	O
Drepper	O
,	O
the	O
glibc	B-Language
maintainer	O
,	O
rejected	O
bcrypt	B-Algorithm
(	O
scheme	O
2	O
)	O
support	O
since	O
it	O
is	O
n't	O
approved	O
by	O
NIST	O
.	O
</s>
<s>
A	O
public	O
domain	O
crypt_blowfish	O
library	O
is	O
available	O
for	O
systems	O
without	O
bcrypt	B-Algorithm
.	O
</s>
<s>
It	O
has	O
been	O
integrated	O
into	O
glibc	B-Language
in	O
SUSE	O
Linux	B-Application
.	O
</s>
<s>
In	O
addition	O
,	O
the	O
aforementioned	O
libxcrypt	O
is	O
used	O
to	O
replace	O
the	O
glibc	B-Language
crypt( )	O
on	O
yescrypt-enabled	O
systems	O
.	O
</s>
<s>
The	O
musl	B-Language
C	O
library	O
supports	O
schemes	O
1	O
,	O
2	O
,	O
5	O
,	O
and	O
6	O
,	O
plus	O
the	O
tradition	O
DES	B-Algorithm
scheme	O
.	O
</s>
<s>
The	O
traditional	O
DES	B-Algorithm
code	O
is	O
based	O
on	O
the	O
BSD	O
FreeSec	O
,	O
with	O
modification	O
to	O
be	O
compatible	O
with	O
the	O
glibc	B-Language
UFC-Crypt	O
.	O
</s>
<s>
Darwin	O
's	O
native	O
crypt( )	O
provides	O
limited	O
functionality	O
,	O
supporting	O
only	O
DES	B-Algorithm
and	O
BSDi	O
.	O
</s>
<s>
OS	O
X	O
uses	O
a	O
few	O
systems	O
for	O
its	O
own	O
password	B-Algorithm
hashes	I-Algorithm
,	O
ranging	O
from	O
the	O
old	O
NeXTStep	O
netinfo	O
to	O
the	O
newer	O
directory	O
services	O
(	O
ds	O
)	O
system	O
.	O
</s>
