DES Cryptography Block Cipher from Delphi

As we know, there are many cryptographic application available in this world. Some of it are commercially, while the rest is free to used by. Well, I was interested on this subject since my curiosity about how to encode and decode a file. This article occasionally intended to my own self after being built a simple cryptography application using Data Encryption Standard (DES) 128 bit algorithms for couple years ago.

The DES method is one of the best way to secure your file. It's workflow is quite simple. To encode, give a string as your digital sign key and embed it into the file. While to decode, give again the string to put back the original file. The initialization procedure to create the block cipher you can see as shown below:

procedure CreateBlockCipher;
const BlockCiphers: array
[0..1] of TBlockCipherClass = (TDESCipher, TBlowfishCipher);
var Key: Int64;
begin
with TDoubleDWORD(Key) do
begin
R := $01234567;
L :=
$89abcdef;
end;
FBlockCipher.Free;
FBlockCipher :=
BlockCiphers[0].Create(Key,SizeOf(Key));
end;
Next below will explain you how to encode and decode the file

Input := TFileStream.Create(InputFileName, fmOpenRead);
Input.Seek(0, soFromBeginning);
InputSize := Input.Size;
CreateBlockCipher;

Output := TFileStream.Create(OutputFileName,
fmCreate);
Output.Seek(0, soFromBeginning);
ShowTransformingLabel(TransformingCaption);
if ((Sender = btnEnkripsi)
or (Sender = Enkripsi1)) then
FBlockCipher.EncryptStream(Input, Output)
else
FBlockCipher.DecryptStream(Input, Output);
And this is the picture of my application:



Next picture describes you the difference between the sample PDF file and the result file:

Sincerelly,

Eko Wahyudiharto
PS: If you've benefit from this blog,
you can support it by making a small contribution.

Enter your email address:

Delivered by FeedBurner

Post a Comment Bookmark and Share

 

  1. Anonymous Anonymous said,

    Sunday, February 08, 2009 8:58:00 PM

    bisa di ownload gx aplikasi n source DES Cryptography Block Cipher from Delphi" nya mas?
    dari:
    sir.ramonez@yahoo.co.id

  2. Blogger Eko Wahyudiharto said,

    Monday, February 09, 2009 11:30:00 AM

    Kalau mau serius, bisa japri saya via email.

  3. Blogger spike said,

    Wednesday, September 22, 2010 11:14:00 PM

    Hi,

    I just wanted to say that I really enjoyed your blog and this post. You make some very informative points. Keep up the great work!

    -
    Delphi development

Post a Comment

Leave comments here...