Crypto Letters and Numbers

Posted on 2012-03-30
Last Modified: 2012-03-30
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;
  iIndex: Integer;
  pIndex: Integer;
  pIndex := 1;

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

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

  Result := InpStr;

Open in new window

Question by:wagnerlimalopes
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
LVL 19

Expert Comment

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

Author Comment

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

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.
LVL 23

Accepted Solution

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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month7 days, 8 hours left to enroll

632 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