From owner-freebsd-questions@freebsd.org Fri Aug 24 08:56:57 2018 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 615561084086 for ; Fri, 24 Aug 2018 08:56:57 +0000 (UTC) (envelope-from matthew@FreeBSD.org) Received: from smtp.infracaninophile.co.uk (smtp.infracaninophile.co.uk [81.2.117.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.infracaninophile.co.uk", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E5E0B7DC0A for ; Fri, 24 Aug 2018 08:56:56 +0000 (UTC) (envelope-from matthew@FreeBSD.org) Received: from leaf.local (unknown [88.202.132.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: m.seaman@infracaninophile.co.uk) by smtp.infracaninophile.co.uk (Postfix) with ESMTPSA id 5C3329E27 for ; Fri, 24 Aug 2018 08:56:34 +0000 (UTC) Authentication-Results: smtp.infracaninophile.co.uk; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: smtp.infracaninophile.co.uk/5C3329E27; dkim=none; dkim-atps=neutral Subject: Re: What hash to use To: freebsd-questions@freebsd.org References: From: Matthew Seaman Message-ID: Date: Fri, 24 Aug 2018 09:56:26 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Aug 2018 08:56:57 -0000 On 24/08/2018 03:25, Olivier wrote: > "Derek (freebsd lists)" <482254ac@razorfever.net> writes: > >> On 2018-08-23 05:16 AM, Olivier wrote: >>> I am using a tools that hashes the passwords in the form of >>> $2b$10$OQBll77HJqnOR.zqK2jx8ukE6m68Azc7nrsgRdcT6bVfERRmzFV4. >>> >>> What magic tool can I use in freeBSD to do the same hashing? >>> >> >> Try this (cdemo.c): >> >> >> >> Then: >> >> cc -lcrypt -o cdemo cdemo.c >> ./cdemo >> >> This is okay for a one-off. >> >> You might wire stdin to read the salt, or for bonus points make >> your own salt generator. >> >> Additionally, it's likely not a good idea to read the password >> from the command-line (argv+argc). A file descriptor (e.g. >> stdin) of some kind would be better, as it will show up in shell >> history and the process table. >> >> Some languages, e.g. python, php, etc will have a library to do >> this for you as well. > > Thank you Derek, I will give it a try. > > I started looking in Perl, but could not find anything. > > I am trying to automatically generate 100 accounts for a software, I > don't want to create them with the web interface, so having the password > on the history is not a problem (and I am asked to have the > password=username, so the quality of password is not a worry :) % perl -le 'print crypt "mypassword", q{$6$RandomSalt$}' $6$RandomSalt$FT6f31B0cyE4q.vCLfpCcAXbX5EYr2fvZW4ILgpUj97sTcZtkHYBGN8FUHUwqN3wkpVPPr/0WIS1FUW4YD9By. The trick is to add the '$6$ (or whatever scheme you prefer) before the salt, and the '$' at the end. Cheers, Matthew