Board index » delphi » Encrypted text in Paradox field - How to ?

Encrypted text in Paradox field - How to ?

I need to encrypt user passwords and keep that encrypted field in a Paradox
table. Sounds simple enough but when I get the encrypted string back out of
the table every 5th char has been changed and my password, of course, is not
unusable. It occured to me to try using a Paradox bytefield but it is not
clear to me the best way to get strings into and out of a byte field.  I've
looked at assign but find it confusing.

Why won't this work with a string field? Is a byte field a good choice? and
How do I get strings into and out of a byte field?  I'm kind of under the
gun to get this done, so anyones prompt reply will be much appreciated.

 

Re:Encrypted text in Paradox field - How to ?


One possibility is that your encryption mechanism produces a zero byte
as one of its possible outputs.  Delphi-32 will happily interpret that
as being the end of the string value.  Your encryption mechanism must
produce a range of output bytes in the range 1..255, excluding zeroes.

Other characters may also be verboten; for example, quote marks.

This is, of course, the same issue that is solved by BinHex, UUEncode,
and MIME.

The "every fifth" problem simply sounds like a bug.

Quote
>MJPruitt wrote:

> I need to encrypt user passwords and keep that encrypted field in a Paradox
> table. Sounds simple enough but when I get the encrypted string back out of
> the table every 5th char has been changed and my password, of course, is not
> unusable. It occured to me to try using a Paradox bytefield but it is not
> clear to me the best way to get strings into and out of a byte field.  I've
> looked at assign but find it confusing.

> Why won't this work with a string field? Is a byte field a good choice? and
> How do I get strings into and out of a byte field?  I'm kind of under the
> gun to get this done, so anyones prompt reply will be much appreciated.

------------------------------------------------------------------------
Sundial Services :: Scottsdale, AZ (USA) :: (480) 946-8259
mailto:i...@sundialservices.com  (PGP public key available.)
Quote
> Got Paradox/Delphi database headaches?  ChimneySweep{tm} can help, FAST!
> http://www.sundialservices.com/cs3web.htm

Re:Encrypted text in Paradox field - How to ?


  I had the some problem a few weeks before. After encripting the password
string  and storing it in a string field, when retrieving the password from
the string field it was altered. You need to check the encription algorithm.
It is possible that it produces as result a string containing some special
control characters with special meaning for paradox.

Re:Encrypted text in Paradox field - How to ?


A string is not any more string but binary data after encryption . So, You
should store this as binary data. So if You don't want to use byte field
(which is confusing to use as You said) You could convert the encrypted data
to hexdecimal string. The length would be twise, but its quite easy to use.

Gert

Quote
> I need to encrypt user passwords and keep that encrypted field in a
Paradox
> table. Sounds simple enough but when I get the encrypted string back out
of
> the table every 5th char has been changed and my password, of course, is
not
> unusable. It occured to me to try using a Paradox bytefield but it is not
> clear to me the best way to get strings into and out of a byte field.
I've
> looked at assign but find it confusing.

> Why won't this work with a string field? Is a byte field a good choice?
and
> How do I get strings into and out of a byte field?  I'm kind of under the
> gun to get this done, so anyones prompt reply will be much appreciated.

Re:Encrypted text in Paradox field - How to ?


Quote
MJPruitt wrote in message <80q9dn$9o...@forums.borland.com>...
>I need to encrypt user passwords and keep that encrypted field in a Paradox
>table. Sounds simple enough but when I get the encrypted string back out of
>the table every 5th char has been changed and my password, of course, is
not
>unusable. It occured to me to try using a Paradox bytefield but it is not
>clear to me the best way to get strings into and out of a byte field.  I've
>looked at assign but find it confusing.

It is possible to do this using Paradox's TBytesField using
SetData and GetData methods.
You can download sample code (6K) to do this at :
http://www.netspace.net.au/~sahn/delphi/pbytes.zip

However, it's probably easier to do what Gert suggested, and
store each byte as a string consisting of two hex digits,
representing each byte. ie. so that all you actually store in
the string field are a sequence of the characters : '0'...'9' .

Stephen

Re:Encrypted text in Paradox field - How to ?


Quote
> However, it's probably easier to do what Gert suggested, and
> store each byte as a string consisting of two hex digits,
> representing each byte. ie. so that all you actually store in
> the string field are a sequence of the characters : '0'...'9' .

Correction: characters '0'..'9','A'..'F'.

Gert

Re:Encrypted text in Paradox field - How to ?


Quote
Gert Kello wrote in message <80rh0f$m...@forums.borland.com>...
>Correction: characters '0'..'9','A'..'F'.

Doh !  Thanks for the correction :)

Stephen.

Re:Encrypted text in Paradox field - How to ?


I think using SetData & GetData are much easier to work than convert one
format to the other

Here is an example:

var
Pwd: string;
begin
SetLength(Pwd, 10);   (* set the maximum lenght *)
ATable.FieldByName('Password').GetData(PChar(Pwd));   (* Get data from table
*)
(* Changing a encrypted password *)
ATable.Edit;
ATable.FieldByName('Password').SetData(PChar(Pwd));
ATable.Post;
end;

Quote
MJPruitt <M...@blackbearsystems.com> wrote in message

news:80q9dn$9o216@forums.borland.com...
Quote
> I need to encrypt user passwords and keep that encrypted field in a
Paradox
> table. Sounds simple enough but when I get the encrypted string back out
of
> the table every 5th char has been changed and my password, of course, is
not
> unusable. It occured to me to try using a Paradox bytefield but it is not
> clear to me the best way to get strings into and out of a byte field.
I've
> looked at assign but find it confusing.

> Why won't this work with a string field? Is a byte field a good choice?
and
> How do I get strings into and out of a byte field?  I'm kind of under the
> gun to get this done, so anyones prompt reply will be much appreciated.

Other Threads