~ubuntu-branches/ubuntu/dapper/fpc/dapper

« back to all changes in this revision

Viewing changes to fcl/tests/tidea.pp

  • Committer: Bazaar Package Importer
  • Author(s): Carlos Laviola
  • Date: 2001-08-29 23:15:17 UTC
  • Revision ID: james.westby@ubuntu.com-20010829231517-thxsp7ctuab584ia
Tags: upstream-1.0.4
ImportĀ upstreamĀ versionĀ 1.0.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Program tidea;
 
2
 
 
3
Uses Classes,Idea;
 
4
 
 
5
Type
 
6
   PByte = ^Byte;
 
7
 
 
8
Var M : TMemorystream;
 
9
    ES : TIDeaEncryptStream;
 
10
    DS : TIdeaDecryptStream;
 
11
    StartKey : ideacryptkey;
 
12
    EnKey,DeKey : ideakey;
 
13
    I,J : longint;
 
14
    
 
15
begin
 
16
  M:=TMemoryStream.create;
 
17
  // generate some phoney key;
 
18
  For I:=0 to SizeOf(StartKey)-1 do
 
19
   PByte(@StartKey)[I]:=I;
 
20
  // Get encryption key
 
21
  EnKeyIdea(StartKey,enKey);
 
22
  ES:=TIDeaEncryptStream.Create(EnKey,M);
 
23
  For I:=1 to 65 do
 
24
    ES.Write(I,SizeOf(I));
 
25
  Writeln ('Position after Write : ',ES.Position);  
 
26
  ES.Flush;
 
27
  Writeln ('Size of memory stream : ',M.Size);
 
28
  M.Seek(0,soFromBeginning);
 
29
  // Get decryption key
 
30
  DeKeyIdea(EnKey,DeKey);
 
31
  DS:=TIDeaDecryptStream.Create(DEKey,M);
 
32
  For I:=1 to 65 do
 
33
    begin
 
34
    DS.Read(J,SizeOf(J));
 
35
    If J<>I then 
 
36
      Writeln ('Error; Read : ',J);
 
37
    end;
 
38
  Writeln ('Position after Reading : ',DS.Position);  
 
39
  DS.destroy;
 
40
end.
 
 
b'\\ No newline at end of file'