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