Solved

Crypto Letters and Numbers

Posted on 2012-03-30
4
355 Views
Last Modified: 2012-03-30
hello
I would like to know how to change the encryption algorithm below for it to return only letters and numbers?

function EncryptDecrypt(InpStr, PassPhrase: string; Salt: Integer): string;
var
  iIndex: Integer;
  pIndex: Integer;
begin
  pIndex := 1;

  for iIndex := 1 to Length(InpStr) do
  begin
      InpStr[iIndex] := Chr(Salt XOR Ord(PassPhrase[pIndex]) XOR Ord(InpStr[iIndex]));
      Inc(Salt);
      Inc(pIndex);

      if (pIndex > Length(PassPhrase)) then
         pIndex := 1;
  end;

  Result := InpStr;
end;

Open in new window



thanks
Wagner
0
Comment
Question by:wagnerlimalopes
4 Comments
 
LVL 19

Expert Comment

by:Thommy
ID: 37787229
If you change encryption, you will have to change decryption, too!!!
0
 

Author Comment

by:wagnerlimalopes
ID: 37787363
even having to separate the encryption and decryption codes, what is the solution?

wagner
0
 
LVL 26

Assisted Solution

by:Sinisa Vuk
Sinisa Vuk earned 250 total points
ID: 37787405
Do simple base64 encode after you do encrypt and base64 decode before you do decrypt.

http://www.swissdelphicenter.ch/torry/showcode.php?id=1524

http://www.delphipraxis.net/991-base64-mime-en-decoding.html
0
 
LVL 22

Accepted Solution

by:
Ferruccio Accalai earned 250 total points
ID: 37787440
Thommy, sometimes I don't understand your comments.
The function posted by him recursively crypts or decrypts a string giving a pass string and a salt.
@wagnerlimalopes: what is the solution?
I guess there's not solution for what you're asking, using this kind of function, as any parameter you pass could be so variable that it could result in at least one non standard alphanumeric character
To get what you need you should use another kind of encryption/decryption script, or insert some other code to force the range of any character into the alphanumeric range
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Newbie Thread Programming 1 139
Communication Between RC4 Delphi <-> PHP 3 101
When I am typing into a TEdit last word repeats 7 117
When i run adoquery my application freezes 26 152
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now