Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ius95-0008WT-Rq for pgsql-general@arkaria.postgresql.org; Fri, 24 Jan 2020 06:08:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ius94-0002hV-MX for pgsql-general@arkaria.postgresql.org; Fri, 24 Jan 2020 06:08:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ius94-0002hN-DB for pgsql-general@lists.postgresql.org; Fri, 24 Jan 2020 06:08:42 +0000 Received: from ms-10.1blu.de ([178.254.4.101]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ius8x-0001s2-2V for pgsql-general@lists.postgresql.org; Fri, 24 Jan 2020 06:08:42 +0000 Received: from [188.174.50.133] (helo=localhost.unixarea.de) by ms-10.1blu.de with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.86_2) (envelope-from ) id 1ius8v-0006wD-F5 for pgsql-general@lists.postgresql.org; Fri, 24 Jan 2020 07:08:33 +0100 Received: from localhost.my.domain (localhost [127.0.0.1]) by localhost.unixarea.de (8.15.2/8.14.9) with ESMTPS id 00O68V0S003023 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO) for ; Fri, 24 Jan 2020 07:08:32 +0100 (CET) (envelope-from guru@unixarea.de) Received: (from guru@localhost) by localhost.my.domain (8.15.2/8.14.9/Submit) id 00O68VBb003022 for pgsql-general@lists.postgresql.org; Fri, 24 Jan 2020 07:08:31 +0100 (CET) (envelope-from guru@unixarea.de) X-Authentication-Warning: localhost.my.domain: guru set sender to guru@unixarea.de using -f Date: Fri, 24 Jan 2020 07:08:31 +0100 From: Matthias Apitz To: pgsql-general@lists.postgresql.org Subject: Re: calculating the MD5 hash of role passwords in C Message-ID: <20200124060831.GA2971@c720-r342378> Reply-To: Matthias Apitz References: <20200122182036.GA2908@c720-r342378> <20200122185847.GA90048@elch.exwg.net> <20200122194113.GA2410@c720-r342378> <20200123161537.GA31330@squirrel.exwg.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200123161537.GA31330@squirrel.exwg.net> X-Operating-System: FreeBSD 13.0-CURRENT r342378 (amd64) X-message-flag: Mails containing HTML will not be read! Please send only plain text. User-Agent: Mutt/1.11.1 (2018-12-01) X-Con-Id: 51246 X-Con-U: 0-guru X-Originating-IP: 188.174.50.133 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk El día jueves, enero 23, 2020 a las 05:15:37p. m. +0100, Christoph Moench-Tegeder escribió: > ## Matthias Apitz (guru@unixarea.de): > > > > The documentation on pg_authid has the details: > > > "The MD5 hash will be of the user's password concatenated to their user name." > > > https://www.postgresql.org/docs/12/catalog-pg-authid.html > > > > This is still not exactly what I was looking for. But has an interesting > > detail (salting the role password by adding the role name to it). An > > implementation with UNIX crypt(3) for MD5 would need an additional salt > > like '$1$salt' to encrypt 'sisis123sisis'. > > It's not crypt(3). It's "the MD5 hash of the user's password concatenated > to their user name". > Try: > perl -MDigest::MD5 -e 'print("md5" . Digest::MD5::md5_hex("sisis123" . "sisis") . "\n");' Thanks! Or one can use: $ echo -n sisis123sisis | openssl md5 | sed 's/^.* /md5/' md52f128a1fbbecc4b16462e8fc8dda5cd5 $ perl -MDigest::MD5 -e 'print("md5" . Digest::MD5::md5_hex("sisis123" . "sisis") . "\n");' md52f128a1fbbecc4b16462e8fc8dda5cd5 matthias -- Matthias Apitz, ✉ guru@unixarea.de, http://www.unixarea.de/ +49-176-38902045 Public GnuPG key: http://www.unixarea.de/key.pub