Re: storing binary data

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Neil Conway <nconway(at)klamath(dot)dyndns(dot)org>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: storing binary data
Date: 2000-10-17 03:22:40
Message-ID: 28942.971752960@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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?

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Neil Conway 2000-10-17 03:40:09 Re: storing binary data
Previous Message Neil Conway 2000-10-17 02:54:09 storing binary data