1.\" $NetBSD: pwhash.1,v 1.11 2021/10/20 17:30:28 nia Exp $ 2.\" $OpenBSD: encrypt.1,v 1.16 2000/11/09 17:52:07 aaron Exp $ 3.\" 4.\" Copyright (c) 1996, Jason Downs. All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS 16.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18.\" DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, 19.\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25.\" SUCH DAMAGE. 26.\" 27.Dd October 20, 2021 28.Dt PWHASH 1 29.Os 30.Sh NAME 31.Nm pwhash 32.Nd hashes passwords from the command line or standard input 33.Sh SYNOPSIS 34.Nm pwhash 35.Op Fl km 36.Op Fl A Ar variant[,params] 37.Op Fl b Ar rounds 38.Op Fl S Ar rounds 39.Op Fl s Ar salt 40.Op Fl p | Ar string 41.Sh DESCRIPTION 42.Nm 43prints the encrypted form of 44.Ar string 45to the standard output. 46This is mostly useful for encrypting passwords from within scripts. 47.Pp 48The options are as follows: 49.Bl -tag -width Ds 50.It Fl b Ar rounds 51Encrypt the string using Blowfish hashing with the specified 52.Ar rounds . 53.It Fl k 54Run in 55.Xr makekey 8 56compatible mode. 57A single combined key (eight chars) and salt (two chars) with no 58intermediate space are read from standard input and the DES encrypted 59result is written to standard output without a terminating newline. 60.It Fl m 61Hash the string using MD5. 62.It Fl p 63Prompt for a single string with echo turned off. 64.It Fl S Ar rounds 65Encrypt the salt with HMAC-SHA1 using the password as key and the specified 66.Ar rounds 67as a hint for the number of iterations. 68.It Fl A Ar variant[,params] 69Encrypt the specified string using Argon2 hashing parameterized using 70variant 71.Ar variant , 72where 73.Ar variant 74is one of the following: argon2id, argon2i, argon2d. Variant 75.Ar argon2id 76is recommended. 77 78Following the required 79.Ar variant 80name, three optional comma-delimited parameters may be provided, 81 82t=n Specify the number of iterations to n. 83 84m=n Specify the memory usage in KB to n. 85 86p=n Specify the number of threads to n. 87This is currently ignored. 88 89If unspecified, default parameters are calculated based on system 90performance and available resources. 91.It Fl s Ar salt 92Encrypt the string using DES, with the specified 93.Ar salt . 94.El 95.Pp 96If no 97.Ar string 98is specified, 99.Nm 100reads one string per line from standard input, encrypting each one 101with the chosen algorithm from above. 102In the event that no specific algorithm is given as a command line option, 103the algorithm specified in the default class in 104.Pa /etc/passwd.conf 105will be used. 106.Pp 107For MD5, Blowfish, and Argon2 a new random salt is automatically generated for each 108password. 109.Pp 110Specifying the 111.Ar string 112on the command line should be discouraged; using the 113standard input is more secure. 114.Sh EXAMPLES 115The following specifies the argon2id variant, using 1 thread and 4096KB of memory 116 117pwhash -A argon2id,p=1,m=4096 -p 118 119 120.Sh FILES 121.Bl -tag -width /etc/passwd.conf -compact 122.It Pa /etc/passwd.conf 123.El 124.Sh SEE ALSO 125.Xr crypt 3 , 126.Xr passwd.conf 5 127