pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedHow are md5.h: pg_md5_hash() function and below functions working?
3+ messages / 3 participants
[nested] [flat]
* How are md5.h: pg_md5_hash() function and below functions working?
@ 2022-01-08 13:21 Ali Koca <kinetixcicocuk@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Ali Koca @ 2022-01-08 13:21 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
I can't understand functions in md5.h, these are seemingly little bit
weird. Such as:
/* Utilities common to all the MD5 implementations,
as of md5_common.c */
extern bool pg_md5_hash(const void *buff, size_t len, char *hexsum);
extern bool pg_md5_binary(const void *buff, size_t len, void *outbuf);
extern bool pg_md5_encrypt(const char *passwd, const char *salt,
size_t salt_len, char *buf);
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: How are md5.h: pg_md5_hash() function and below functions working?
@ 2022-01-08 16:12 Adrian Klaver <adrian.klaver@aklaver.com>
parent: Ali Koca <kinetixcicocuk@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Adrian Klaver @ 2022-01-08 16:12 UTC (permalink / raw)
To: Ali Koca <kinetixcicocuk@gmail.com>; pgsql-general@lists.postgresql.org
On 1/8/22 05:21, Ali Koca wrote:
> I can't understand functions in md5.h, these are seemingly little bit
> weird. Such as:
>
> /* Utilities common to all the MD5 implementations,
> as of md5_common.c */
> extern bool pg_md5_hash(const void *buff, size_t len, char *hexsum);
> extern bool pg_md5_binary(const void *buff, size_t len, void *outbuf);
> extern bool pg_md5_encrypt(const char *passwd, const char *salt,
> size_t salt_len, char *buf);
>
>
What they do is explained in md5_common.c.
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: How are md5.h: pg_md5_hash() function and below functions working?
@ 2022-01-22 06:11 Michael Paquier <michael@paquier.xyz>
parent: Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 0 replies; 3+ messages in thread
From: Michael Paquier @ 2022-01-22 06:11 UTC (permalink / raw)
To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: Ali Koca <kinetixcicocuk@gmail.com>; pgsql-general@lists.postgresql.org
On Sat, Jan 08, 2022 at 08:12:50AM -0800, Adrian Klaver wrote:
> On 1/8/22 05:21, Ali Koca wrote:
>> I can't understand functions in md5.h, these are seemingly little bit
>> weird. Such as:
>> /* Utilities common to all the MD5 implementations,
>> as of md5_common.c */
>> extern bool pg_md5_hash(const void *buff, size_t len, char *hexsum);
>> extern bool pg_md5_binary(const void *buff, size_t len, void *outbuf);
>> extern bool pg_md5_encrypt(const char *passwd, const char *salt,
>> size_t salt_len, char *buf);
>
> What they do is explained in md5_common.c.
pg_md5_hash() and pg_md5_binary() do the same thing, by computing a
MD5. pg_md5_hash() computes it as a string in hex format, meaning
that it is 33-character long with the final trailing '\0'.
pg_md5_binary() computes 16 raw bytes.
pg_md5_encrypt() is a utility wrapper that does the operation of
pg_md5_hash() based on a password and a salt, used at authentication
time for MD5. Its result is a 36-byte long string, prefixed with
"md5" and a 33-byte long hex string. Those routine names are
historic.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2022-01-22 06:11 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-01-08 13:21 How are md5.h: pg_md5_hash() function and below functions working? Ali Koca <kinetixcicocuk@gmail.com>
2022-01-08 16:12 ` Adrian Klaver <adrian.klaver@aklaver.com>
2022-01-22 06:11 ` Michael Paquier <michael@paquier.xyz>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox