Solved

Crypto Letters and Numbers

Posted on 2012-03-30
4
353 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 25

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 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

13 Experts available now in Live!

Get 1:1 Help Now