EP_ProtectedStringByKey
EP_ProtectedStringByKey 使用密钥,函数返回被保护字符串。参看 加密字符串。
参数
- Key - 被保护字符串对应密钥。
- Buffer - 被保护内容转换,如果为空,函数返回被保护内容大小。
- Len - 被保护内容大小(长度)。
返回值
如果函数成功执行,返回值为被保护字符串,否则为0。
备注
在以下情况函数不能成功执行:
定义
Show/Hide C++ function definition
extern "C" __declspec( dllimport ) __stdcall int EP_ProtectedStringByKey( char* Key, char* Left, int Len);
Show/Hide Delphi function definition
function EP_ProtectedStringByKey(Key : pchar; Buffer : pointer; Len : integer) : integer; stdcall;
Show/Hide Visual Basic function definition
Public Declare Function EP_ProtectedStringByKey Lib "enigma_ide.dll" (ByVal Key As String, ByVal Str As String, ByVal Length As Byte) As Byte
Show/Hide C# (.NET) function definition
public class Enigma_IDE
{
[DllImport("enigma_ide.dll", CallingConvention = CallingConvention.StdCall)]
public static extern Int32 EP_ProtectedStringByKey(string Key, StringBuilder Str, Int32 Len);
}
实例
Show/Hide Delphi function example
uses
enigma_ide;
procedure TForm1.FormShow(Sender: TObject);
var
str : shortstring;
len : byte;
arr : array [0..MAX_STRING_SIZE - 1] of char;
buflen : integer;
buf : pointer;
begin
len := EP_ProtectedStringByKey('fyi6z02Y', @str[1], sizeof(str));
if len > 0 then
begin
str[0] := char(len);
Edit1.Text := str;
end;
ZeroMemory(@arr, sizeof(arr));
if EP_ProtectedStringByID(1, @arr, sizeof(arr)) > 0 then
begin
Edit2.Text := arr;
end;
buflen := EP_ProtectedStringByKey('26Lu66Er', nil, 0);
if buflen > 0 then
begin
GetMem(buf, buflen + 1);
ZeroMemory(buf, buflen + 1);
if EP_ProtectedStringByKey('26Lu66Er', buf, buflen) > 0 then
begin
Edit3.Text := pchar(buf);
end;
FreeMem(buf);
end;
end;
Show/Hide C# (.NET) function example
private void Form1_Shown(object sender, EventArgs e)
{
Int32 len = Enigma_IDE.EP_ProtectedStringByKey("fyi6z02Y", null, 0);
if (len > 0)
{
StringBuilder str = new StringBuilder(len);
if (Enigma_IDE.EP_ProtectedStringByKey("fyi6z02Y", str, len) > 0)
{
textBox1.Text = str.ToString();
}
}
len = Enigma_IDE.EP_ProtectedStringByID(1, null, 0);
if (len > 0)
{
StringBuilder str = new StringBuilder(len);
if (Enigma_IDE.EP_ProtectedStringByID(1, str, len) > 0)
{
textBox2.Text = str.ToString();
}
}
len = Enigma_IDE.EP_ProtectedStringByKey("26Lu66Er", null, 0);
if (len > 0)
{
StringBuilder str = new StringBuilder(len);
if (Enigma_IDE.EP_ProtectedStringByKey("26Lu66Er", str, len) > 0)
{
textBox3.Text = str.ToString();
}
}
}
Show/Hide Visual Basic function example
Private Sub Form_Load()
Dim Lenght As Byte
Dim Str As String
Length = EP_ProtectedStringByKey("fyi6z02Y", vbNullString, 0)
Str = String$(Length, 0)
If EP_ProtectedStringByKey("fyi6z02Y", Str, Length) > 0 Then
Text1.Text = Str
End If
Length = EP_ProtectedStringByID(1, vbNullString, 0)
Str = String$(Length, 0)
If EP_ProtectedStringByID(1, Str, Length) > 0 Then
Text2.Text = Str
End If
Length = EP_ProtectedStringByKey("26Lu66Er", vbNullString, 0)
Str = String$(Length, 0)
If EP_ProtectedStringByKey("26Lu66Er", Str, Length) > 0 Then
Text3.Text = Str
End If
可以在安装文件夹下 Examples\ProtectedStrings 子文件夹里查看函数使用实例。