RSA Delphi
description
Transcript of RSA Delphi
aluiken:
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;