Re: Random strings
Joe Conway <joseph.conway@home.com>
From: "Joe Conway" <joseph.conway@home.com>
To: "Joe Conway" <joseph.conway@home.com>,
"Peter Eisentraut" <peter_e@gmx.net>
Cc: "Dr. Evil" <drevil@sidereal.kz>, <pgsql-patches@postgresql.org>
Date: 2001-08-09T07:02:58Z
Lists: pgsql-general
Attachments
- randomstr_r02.diff (application/octet-stream) patch
> > Perhaps one of these returning bytea would be enough and you can use > > the new encode functions to convert them to a format of choice. Also, why > > aren't you using /dev/random? > Here's a revised patch. This one has only one user function, randomstr(int binlen, text source). It allows any length request (well, limited by int) against a source of 'urandom', or a maximum of 64 bytes against a source of 'random'. I also added a couple of examples to the readme to show how to use randomstr() with encode() to get hex or base64 output. On a side note, in the last version of this, I had a function which escaped the binary C string so that I could feed it to byteain. In this version, I decided to populate the varlena struct directly, because it seemed an awful waste to escape the binary just so that byteain could unescape it. But I'm not sure this is considered a "good thing", or a "bad thing". I'd appreciate any guidance. Thanks, Joe