Hello friends,
I want to create a unit with the following code:
unit unit_ciphers;
{$mode objfpc}
interface
uses
Classes, SysUtils, DCPblowfish, DCPrijndael, DCPserpent, DCPidea, DCPmars,
DCPtwofish, DCPcast128, DCPcast256, DCPdes, DCPice, DCPtea, DCPsha1,
DCPsha256, DCPmd5;
implementation
function Code(key:string; uncrypted_string:string; level:integer):string; {$ifndef linux} stdcall; {$else} cdecl; {$endif} //Encode(key, text, level)
var
motor: TDCP_blowfish;
i: integer;
t: string;
begin
if level=0
then level:=1
else if level>2
then level:=2;
motor:=TDCP_blowfish.Create(nil);
t:=uncrypted_string;
for i:=1 to level do begin
motor.InitStr(key,TDCP_sha256);
t:=motor.EncryptString(t);
motor.Burn;
end;
result:=t;
motor.Free;
end;
function Decode(key:string; crypted_string:string; level:integer):string; {$ifndef linux} stdcall; {$else} cdecl; {$endif} //Decode(key, text, level)
var
motor: TDCP_blowfish;
i: integer;
t: string;
begin
if level=0
then level:=1
else if level>2
then level:=2;
motor:=TDCP_blowfish.Create(nil);
t:=crypted_string;
for i:=1 to level do begin
motor.InitStr(key,TDCP_sha256);
t:=motor.DecryptString(t);
motor.Burn;
end;
result:=t;
motor.Free;
end;
end.
In other unit (the main one) I specify uses "unit_ciphers" with the believe that it would make accessible all the contents of the
"used" units. But not. When compiling I find that:
(buffer is a string)
if CheckBox1.Checked = True then begin
buffer := Code('aDc32bBlmBvCx283sdDwZz', EditSend.Text, 1);
FNet.SendMessage(buffer);
end;
gives an error Identifier not found "Code".
Whats wrong with unit_cipher? I still don't seem to manage this kind of situations.
regards