I have a delphi function that I export as dll, here I leave my code:
library MdEncDec;
uses
System.SysUtils,
System.Classes,
Bcrypt;
{$R *.res}
function EncryptWord( value: PChar ): ShortString; stdcall; export;
var
BCRYPT1: TBCRYPT;
begin
BCRYPT1 := TBCRYPT.create( nil );
try
BCRYPT1.AlphaMode := False;
BCRYPT1.AlphaMode := True;
BCRYPT1.Mode := MODE_ENCRYPT;
BCRYPT1.InString := value;
Result := BCRYPT1.OutString;
finally
BCRYPT1.Free;
end;
end;
function DecryptWord( value: PChar ): ShortString; stdcall; export;
var
BCRYPT1: TBCRYPT;
begin
BCRYPT1 := TBCRYPT.create( nil );
try
BCRYPT1.AlphaMode := False;
BCRYPT1.AlphaMode := True;
BCRYPT1.Mode := MODE_DECRYPT;
BCRYPT1.InString := value;
Result := BCRYPT1.OutString;
finally
BCRYPT1.Free;
end;
end;
exports EncryptWord, DecryptWord;
begin
end.
At the time of consuming it in c # I did the following:
[DllImport("MdEncDec.dll", CharSet = CharSet.Unicode, CallingConvention
=CallingConvention.StdCall)]
public static extern string
EncryptWord([MarshalAs(UnmanagedType.LPWStr)] string cadena);
Console.WriteLine(EncryptWord("Test"));
Console.ReadLine();
This gives me problems does not show me the encrypted string that is the function of the delphi, at the end it does not show me anything, I already compile the 32 and 64 bit dll in debug and release mode I do not know what else to do, if someone has knowledge about this and you could help me, I'd appreciate it, I've been here a week.
Thanks