source: cprs/branches/GUI-config/BDK32/Source/Hash.pas@ 530

Last change on this file since 530 was 476, checked in by Kevin Toppenberg, 16 years ago

New WorldVistA Config Utility

File size: 3.7 KB
RevLine 
[476]1{ **************************************************************
2 Package: XWB - Kernel RPCBroker
3 Date Created: Sept 18, 1997 (Version 1.1)
4 Site Name: Oakland, OI Field Office, Dept of Veteran Affairs
5 Developers: Wally Fort, Joel Ivey
6 Description: Encryption and decryption functions.
7 Current Release: Version 1.1 Patch 40 (January 7, 2005))
8*************************************************************** }
9
10unit Hash;
11
12
13interface
14
15uses SysUtils, Classes;
16
17
18{function and procedure prototypes}
19function Decrypt(EncryptedText: string): string;
20function Encrypt(NormalText: string): string;
21
22const
23 maxKeys = 20;
24 CipherPad: array[0..maxKeys - 1] of string = (
25
26 'wkEo-ZJt!dG)49K{nX1BS$vH<&:Myf*>Ae0jQW=;|#PsO`''%+rmb[gpqN,l6/hFC@DcUa ]z~R}"V\iIxu?872.(TYL5_3',
27 'rKv`R;M/9BqAF%&tSs#Vh)dO1DZP> *fX''u[.4lY=-mg_ci802N7LTG<]!CWo:3?{+,5Q}(@jaExn$~p\IyHwzU"|k6Jeb',
28 '\pV(ZJk"WQmCn!Y,y@1d+~8s?[lNMxgHEt=uw|X:qSLjAI*}6zoF{T3#;ca)/h5%`P4$r]G''9e2if_>UDKb7<v0&- RBO.',
29 'depjt3g4W)qD0V~NJar\B "?OYhcu[<Ms%Z`RIL_6:]AX-zG.#}$@vk7/5x&*m;(yb2Fn+l''PwUof1K{9,|EQi>H=CT8S!',
30 'NZW:1}K$byP;jk)7''`x90B|cq@iSsEnu,(l-hf.&Y_?J#R]+voQXU8mrV[!p4tg~OMez CAaGFD6H53%L/dT2<*>"{\wI=',
31 'vCiJ<oZ9|phXVNn)m K`t/SI%]A5qOWe\&?;jT~M!fz1l>[D_0xR32c*4.P"G{r7}E8wUgyudF+6-:B=$(sY,LkbHa#''@Q',
32 'hvMX,''4Ty;[a8/{6l~F_V"}qLI\!@x(D7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HA4C''?Mv\Pq{n#56LftUl@9+',
43 '~A*>9 WidFN,1KsmwQ)GJM{I4:C%}#Ep(?HB/r;t.&U8o|l[''Lg"2hRDyZ5`nbf]qjc0!zS-TkYO<_=76a\X@$Pe3+xVvu',
44 'yYgjf"5VdHc#uA,W1i+v''6|@pr{n;DJ!8(btPGaQM.LT3oe?NB/&9>Z`-}02*%x<7lsqz4OS ~E$\R]KI[:UwC_=h)kXmF',
45 '5:iar.{YU7mBZR@-K|2 "+~`M%8sq4JhPo<_X\Sg3WC;Tuxz,fvEQ1p9=w}FAI&j/keD0c?)LN6OHV]lGy''$*>nd[(tb!#');
46
47implementation
48
49uses mfunstr {for Translate function};
50
51
52function Encrypt(normalText: string): string;
53var
54 associatorIndex, identifierIndex: integer;
55begin
56 Randomize;
57 associatorIndex := random(MaxKeys);
58 repeat
59 identifierIndex := Random(MaxKeys);
60 until associatorIndex <> identifierIndex; {make sure indexes are different}
61
62 Result := chr(AssociatorIndex+32) +
63 Translate(NormalText, CipherPad[AssociatorIndex],
64 CipherPad[IdentifierIndex]) +
65 chr(identifierIndex+32);
66end;
67
68
69
70function Decrypt(EncryptedText: string): string;
71var
72 AssociatorIndex, IdentifierIndex: integer;
73begin
74 IdentifierIndex := Ord(EncryptedText[1])-32;
75 AssociatorIndex := Ord(EncryptedText[Length(EncryptedText)])-32;
76 Result := Translate(copy(EncryptedText,2,Length(EncryptedText)-2),
77 CipherPad[AssociatorIndex],
78 CipherPad[IdentifierIndex]);
79end;
80
81end.
Note: See TracBrowser for help on using the repository browser.