Solved

Crypto Letters and Numbers

Posted on 2012-03-30
4
358 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 27

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

752 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