Solved

RSA Algorithm in Delphi 3

Posted on 1997-11-25
1
1,748 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

830 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