esk
asked on
Encrypt string and decrypt string
Hi
i have value in edit box some i want to encrypt, and be able to decypt it again
Esk
i have value in edit box some i want to encrypt, and be able to decypt it again
Esk
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Just how secure do want this to be?
Do you have to worry about leaving un-encrypted values in ram/on disk?
GL
Mike
Do you have to worry about leaving un-encrypted values in ram/on disk?
GL
Mike
Try
http://torry.9bit.qc.ca/vcl/security/dncryptlib.zip
or any other component on
http://torry.9bit.qc.ca/security.htm
http://torry.9bit.qc.ca/vcl/security/dncryptlib.zip
or any other component on
http://torry.9bit.qc.ca/security.htm
this was posted in another q some time ago. it is similar to aubs first comment :
using a random number up to 26 is used to offset each char. This way the string returned will always be readable, but much harder to decrypt because the offset is different every time.
You may want to alter the seed value, but there is no real advantage to this. MAKE SURE THE SEED IS THE SAME FOR ENCRYPTION AND DECRYTION!
function EncryptPassword(password: string): string;
var
i: integer;
begin
RandSeed:= 9999;
for i:= 1 to length(password) do
password[i]:= chr(ord(password[i]) + random(26));
Result:= Password;
end;
function DecryptPassword(s: string): string;
var
i: integer;
begin
s:='';
RandSeed:= 9999;
for i:= 1 to length(s) do
s[i]:= chr(ord(s[i]) - random(26));
Result:= s;
end;
using a random number up to 26 is used to offset each char. This way the string returned will always be readable, but much harder to decrypt because the offset is different every time.
You may want to alter the seed value, but there is no real advantage to this. MAKE SURE THE SEED IS THE SAME FOR ENCRYPTION AND DECRYTION!
function EncryptPassword(password: string): string;
var
i: integer;
begin
RandSeed:= 9999;
for i:= 1 to length(password) do
password[i]:= chr(ord(password[i]) + random(26));
Result:= Password;
end;
function DecryptPassword(s: string): string;
var
i: integer;
begin
s:='';
RandSeed:= 9999;
for i:= 1 to length(s) do
s[i]:= chr(ord(s[i]) - random(26));
Result:= s;
end;
The 'cryptlib' I mentioned before is not the right one. This one is:
http://www3.ewebcity.com/joep/cryptlib.zip
http://www3.ewebcity.com/joep/cryptlib.zip
you can also use random chars up to 255 and then pass the number to HEX and to string, that way it's always readable also, but is double lenght than original
esk,
It all depends what you want to do with the data. If you're going to encrypt the data into a file, and then decrypt it back when you read it out then there are better solutions than aubs. But if you actually want to encrypt the data as the user enters it then the code already supplied will do the job.
Bear in mind that aubs system isn't too complex of difficult to crack. Personally I'd go for a password overlay system. Basically it involves combining characters as ASCII values from a password. The encrypted text changes according to the password. It's not foolproof but is a little more advanced that what you've already been told.
If you want encryption and decryption routines for this then just ask
The Neil
It all depends what you want to do with the data. If you're going to encrypt the data into a file, and then decrypt it back when you read it out then there are better solutions than aubs. But if you actually want to encrypt the data as the user enters it then the code already supplied will do the job.
Bear in mind that aubs system isn't too complex of difficult to crack. Personally I'd go for a password overlay system. Basically it involves combining characters as ASCII values from a password. The encrypted text changes according to the password. It's not foolproof but is a little more advanced that what you've already been told.
If you want encryption and decryption routines for this then just ask
The Neil
you can also use Microsofts CryptoAPI
http://www.DelphiZine.com/features/1999/02/di199902mb_f/di199902mb_f.asp
Regards, Zif.
http://www.DelphiZine.com/features/1999/02/di199902mb_f/di199902mb_f.asp
Regards, Zif.
ASKER
Jaymol, can you sent me demo at esk10000@hotmail.com
homesite did not work here!!!
Esk
homesite did not work here!!!
Esk
ASKER
aubs, your functions won't work
ASKER
aubs, this works, my compiler was $%/%&
So does it work or does it not work?
Aubs
Aubs
ASKER
It works
thanks
Esk
thanks
Esk
http://www.freehomepages.com/secretdelphi/
(Suprised you didn't ask me about this in the 1st place!)
John.