Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# Crypto Letters and Numbers

Posted on 2012-03-30
Medium Priority
362 Views
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;
``````

thanks
Wagner
0
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

LVL 19

Expert Comment

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

Author Comment

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

wagner
0

LVL 27

Assisted Solution

Sinisa Vuk earned 750 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 23

Accepted Solution

Ferruccio Accalai earned 750 total points
ID: 37787440
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

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
###### Suggested Courses
Course of the Month10 days, 4 hours left to enroll