Re: Re: Now for the VARDATA, VARSIZE, and VARHDRSZ stuff
От | Lonnie Cumberland |
---|---|
Тема | Re: Re: Now for the VARDATA, VARSIZE, and VARHDRSZ stuff |
Дата | |
Msg-id | 20010420131202.44750.qmail@web12503.mail.yahoo.com обсуждение исходный текст |
Ответ на | Re: Now for the VARDATA, VARSIZE, and VARHDRSZ stuff (Brendan Guenther <guenthe8@msu.edu>) |
Список | pgsql-interfaces |
Hello Brendan, I too was having this problem, but now think that I am getting a very good handle on these interfaces. Being that you are trying to hash the standard unix crypt function to look over the password file, I think that this solution might help you. I have a simple an efficient C++ solution to this problem: My "unixcrypt" functions now looks like this --------------------------------------------------------------- text *unix_encrypt(text *inarg, text *inpass) { char temp[25]; int temp_len; // Take the "text" variables directly to the "strings" string instr(VARDATA(inarg),0,VARSIZE(inarg)-VARHDRSZ); string passPhrase(VARDATA(inpass),0,VARSIZE(inpass)-VARHDRSZ); strcpy(temp,crypt(instr.c_str(),passPhrase.c_str())); temp_len=strlen(temp); string outstr(temp,0,temp_len); // Set up the outgoing DB "text" variable int32 new_text_size = outstr.size()+4; text *new_text = (text *) palloc(new_text_size); memset((void *) new_text, 0, new_text_size); VARATT_SIZEP(new_text) = new_text_size; // Move the variable over from the string strncpy(VARDATA(new_text),outstr.c_str(),outstr.size()); return new_text; } ---------------------------------------------------------------------------- Be sure to include the header: #include <unistd.h> // for unix crypt function --------------------------------------------------------------------------- hope that this helps, Lonnie --- Brendan Guenther <guenthe8@msu.edu> wrote: > > > Peter Eisentraut wrote: > > > The best things might be not to mess with this but call textin() and > > textout() to convert your data to C strings. > > I can't seem to find documentation for textin() and textout() can somebody > point > me in the right direction for this or provide an example. I'm having similar > problems that Lonnie is having with VARDATA and I think this might help. I'm > trying to link in a C function that makes use of OpenSSL's libcrypto > functions. > > Basically I just need to hash and verify passwords in the database, so as an > alternate question, if I'm missing something and there is a better way to do > password storage let me know. > > Thanks, > -- > Brendan Guenther > guenthe8@msu.edu > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://www.postgresql.org/search.mpl __________________________________________________ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/
В списке pgsql-interfaces по дате отправления: