1 /* Verify a passphrase.
2 Copyright (C) 1991-2018 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, if not, see <http://www.gnu.org/licenses/>.
23 /* @samp{GNU's Not Unix} hashed using SHA-256, MD5, and DES. */
24 static const char hash_sha
[] =
25 "$5$DQ2z5NHf1jNJnChB$kV3ZTR0aUaosujPhLzR84Llo3BsspNSe4/tsp7VoEn6";
26 static const char hash_md5
[] = "$1$A3TxDv41$rtXVTUXl2LkeSV0UU5xxs1";
27 static const char hash_des
[] = "FgkTuF98w5DaI";
35 /* Prompt for a passphrase. */
36 phrase
= getpass ("Enter passphrase: ");
38 /* Compare against the stored hashes. Any input that begins with
39 @samp{GNU's No} will match the DES hash, but the other two will
40 only match @samp{GNU's Not Unix}. */
42 if (strcmp (crypt (phrase
, hash_sha
), hash_sha
))
50 if (strcmp (crypt (phrase
, hash_md5
), hash_md5
))
58 if (strcmp (crypt (phrase
, hash_des
), hash_des
))