From: | Neil Conway <nconway(at)klamath(dot)dyndns(dot)org> |
---|---|
To: | PostgreSQL General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: storing binary data |
Date: | 2000-10-17 03:40:09 |
Message-ID: | 20001016234009.A3164@klamath.dyndns.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Mon, Oct 16, 2000 at 11:22:40PM -0400, Tom Lane wrote:
> Neil Conway <nconway(at)klamath(dot)dyndns(dot)org> writes:
> > I want to store some binary data in Postgres. The data is an
> > MD5 checksum of the user's password, in binary. It will be
> > exactly 16 bytes (since it is a one-way hash).
>
> > Can I store this safely in a CHAR column?
>
> No. CHAR and friends assume there are no null (zero) bytes.
> In MULTIBYTE setups there are probably additional constraints.
>
> You could use bytea, but I would recommend converting the checksum
> to a hex digit string and then storing that in a char-type field.
> Hex is the usual textual representation for MD5 values, no?
It is, but (IMHO) it's a big waste of space. The actual MD5 digest is
128 bits. If stored in binary form, it's 16 bytes. If stored in hex
form (as ASCII), it's 32 characters @ 1 byte per character = 32 bytes.
In Unicode, that's 64 bytes (correct me if I'm wrong).
It's not a huge deal, but it would be nice to store this efficiently.
Is this possible?
TIA,
Neil
--
Neil Conway <neilconway(at)home(dot)com>
Get my GnuPG key from: http://klamath.dyndns.org/mykey.asc
Encrypted mail welcomed
Being able to break into computers doesn't make you a hacker any more
than being able to hotwire cars makes you an automotive engineer.
From | Date | Subject | |
---|---|---|---|
Next Message | Alfred Perlstein | 2000-10-17 03:56:33 | Re: storing binary data |
Previous Message | Tom Lane | 2000-10-17 03:22:40 | Re: storing binary data |