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 22

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 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