Solved

RSA Algorithm in Delphi 3

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month4 days, 13 hours left to enroll

636 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