We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

# RSA Algorithm in Delphi 3

on
Medium Priority
1,809 Views
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
Comment
Watch Question

## View Solution Only

Commented:
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);
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;

Not the solution you were looking for? Getting a personalized solution is easy.

##### Thanks for using Experts Exchange.

• View three pieces of content (articles, solutions, posts, and videos)
• Ask the experts questions (counted toward content limit)
• Customize your dashboard and profile