Solved

RSA Algorithm in Delphi 3

Posted on 1997-11-25
1
1,757 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
[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
  • Learn & ask questions
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

752 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