A simple encryption algorithm

zhaozj2021-02-11  148

At that time, I saw a post, I have called this code, I haven't seriously debugged.

Program project1; {$ appype console} Uses sysutils; const key = 'testnet'; Cryptograph = 'Some things are still unknovical'; // cannot be 0.5, add 1 percent1 = 0.21; percent2 = 0.79; var S1: Function getKey (AKEY: STRING; APERCENT: DOUBLE): String; var i: integer; begin setlength; for i: = 1 to length (akey) do begin Result [i]: = CHR (Round (Akey [i]) * apercent); end; end; function encode (acryptograph, akey: string): String; Var i, keylen, codelen: integer; begin keylen: = Length; akey Codelen: = Length (acryptograph); setlength (result, lengthptograph); for i: = 1 to codelen do beglen Result [i]: = chr (Acryptograph [i]) ORD (Akey [(i mod) Keylen 1]); end; end; function decode (acryptograph, akey: string): string; var I, keylen, codelen: integer; begin keylen: = length (akey); codeln: = length (acryptogram); SETLENGTH (Result, Length); for i: = 1 to Codelen Do Begin Result [I]: = CHR (ORD (Acryptograph [i]) - ORD (Akey [(i mod keylen) 1])) End; end; begin {todo -ouser -cconsole main: insert code he} WRI Teln ('to encrypt the text'); Writeln (Cryptograph); Writeln; Writeln ('password through the first network'); S1: = Encode (Cryptograph, getKey (key, percent1)); Writeln (S1); Writeln Writeln ('password through the second network'); S1: = Encode (S1, getKey (key, percent2)); Writeln (S1); Writeln; Writeln ('Restore'); S1: = DECode (S1, Key Writeln (S1); WRITELN; WRITELN ('If you want to display in the VCL control, the # 0 is processed,' 'Because most of the functions among the VCLs as the end flag'); readln; End.

转载请注明原文地址:https://www.9cbs.com/read-5387.html

New Post(0)