Solved

RSA Algorithm in Delphi 3

Posted on 1997-11-25
1
1,738 Views
Last Modified: 2012-06-22
Does anyone know how to implement the RSA encryption/decryption algorithm in a delphi program. I'm not interested in some DCU, but if someone could just help me get started
0
Comment
Question by:carceri
1 Comment
 
LVL 1

Accepted Solution

by:
aluiken earned 30 total points
ID: 1351804
Hi Carceri,

The encryption key is:   C = M to the power of e MOD n

         where C is the encrypted byte(s)
               M is the byte(s) to be encrypted
               n is the product of p and q
               p is a prime number
               q is a prime number
               e is a number that  gcd(e,(p-1),(q-1)) = 1

  The decryption key is:   M = C to the power of d MOD n

         Where C is the encrypted byte(s)
               M is the original byte(s)
               n is the product of p and q
               p is a prime number
               q is a prime number
               d is the inverse of the module MOD (p-1)(q-1)

So what you have to do now is code a proc something like:

Procedure Encrypt(Fn,OFN : String);
Var I,O : File;
    Cnt : LongInt;
    Buf : Array[1..4096] Of Byte;
Begin
 AssignFile(I,Fn);
 Reset(I,1);
 AssignFile(O,OFn);
 Rewrite(O,1);
  Repeat
   FillChar(Buf,SizeOf(Buf),#0);
   BlockRead(I,Buf,SizeOf(Buf),Nr);
    For Cnt := 1 To 4096 Do Begin
                             Buf[I] := ........
                             Process Encryption Here !
                            End;
   BlockWrite(O,Buf,Nr,Nw);
  Until (Nr <> Nw) Or (Nr = 0);
 Close(O);
 Close(I);
End;
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 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

16 Experts available now in Live!

Get 1:1 Help Now