提供一个封装MIME,XXE,UUE和MD5变换的DLL,附VB和DELPHI调用示例源码
感到使用VB等语言的兄弟调用这些现成的算法比较麻烦,特写个DLL,给大家调用,呵呵。。。。。。。。。MIME也就是BASE64,其它的就不多说了。。。。。。。。
下面的源码是VB.NET写的,把其中的源码拷贝到VB6中也可编译。
把DLL拷贝到所写的VB工程目录下,然后把下面的声明加进去,就可调用了。。。。。。
Public Class Form1
Declare Function EncodeMIME Lib "CryptPrj.dll" (ByVal lpszSource As String, ByVal lpszDst As String) As Long
Declare Function DecodeMIME Lib "CryptPrj.dll" (ByVal lpszSource As String, ByVal lpszDst As String) As Long
Declare Function EncodeXXE Lib "CryptPrj.dll" (ByVal lpszSource As String, ByVal lpszDst As String) As Long
Declare Function DecodeXXE Lib "CryptPrj.dll" (ByVal lpszSource As String, ByVal lpszDst As String) As Long
Declare Function EncodeUUE Lib "CryptPrj.dll" (ByVal lpszSource As String, ByVal lpszDst As String) As Long
Declare Function DecodeUUE Lib "CryptPrj.dll" (ByVal lpszSource As String, ByVal lpszDst As String) As Long
Declare Function MD5 Lib "CryptPrj.dll" (ByVal lpszSource As String, ByVal lpszDst As String) As Long
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim str1 As String
Dim str2 As String
str1 = Space(255)
str2 = TextBox1.Text
Select Case ComboBox1.SelectedIndex
Case 0
EncodeMIME(str2, str1)
Case 1
EncodeXXE(str2, str1)
Case 2
EncodeUUE(str2, str1)
Case 3
MD5(str2, str1)
End Select
TextBox2.Text = str1
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim str1 As String
Dim str2 As String
str1 = Space(255)
str2 = TextBox1.Text
Select Case ComboBox1.SelectedIndex
Case 0
DecodeMIME(str2, str1)
Case 1
DecodeXXE(str2, str1)
Case 2
DecodeUUE(str2, str1)
Case 3
str1 = ""
MsgBox("不支持MD5逆运算")
End Select
TextBox2.Text = str1
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ComboBox1.SelectedIndex = 0
End Sub
End Class
[ 本帖最后由 caterpilla 于 2006-8-2 13:52 编辑 ] 支持一下。。。
附DELPHI调用示例
unit CryptTest;interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
RadioGroup1: TRadioGroup;
Button1: TButton;
Button2: TButton;
procedure RadioGroup1Click(Sender: TObject);
procedure Edit1Change(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
function EncodeMIME(src:PChar;dst:PChar):HRESULT;stdcall;external 'CryptPrj.dll';
function DecodeMIME(src:PChar;dst:PChar):HRESULT;stdcall;external 'CryptPrj.dll';
function EncodeXXE(src:PChar;dst:PChar):HRESULT;stdcall;external 'CryptPrj.dll';
function DecodeXXE(src:PChar;dst:PChar):HRESULT;stdcall;external 'CryptPrj.dll';
function EncodeUUE(src:PChar;dst:PChar):HRESULT;stdcall;external 'CryptPrj.dll';
function DecodeUUE(src:PChar;dst:PChar):HRESULT;stdcall;external 'CryptPrj.dll';
function MD5(src:PChar;dst:PChar):HRESULT;stdcall;external 'CryptPrj.dll';
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
str:string;
begin
SetLength(str,255);
case RadioGroup1.ItemIndex of
0: EncodeMIME(PChar(edit1.Text),PChar(str));
1: EncodeXXE(PChar(edit1.Text),PChar(str));
2: EncodeUUE(PChar(edit1.Text),PChar(str));
3: MD5(PChar(edit1.Text),PChar(str));
end;
edit2.Text:=str;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
str:string;
begin
SetLength(str,255);
case RadioGroup1.ItemIndex of
0: DecodeMIME(PChar(edit1.Text),PChar(str));
1: DecodeXXE(PChar(edit1.Text),PChar(str));
2: DecodeUUE(PChar(edit1.Text),PChar(str));
3: begin
str:='';
ShowMessage('未实现MD5逆运算');
end;
end;
edit2.Text:=str;
end;
procedure TForm1.Edit1Change(Sender: TObject);
begin
Edit2.Text:='';
end;
procedure TForm1.RadioGroup1Click(Sender: TObject);
begin
edit2.Text:='';
end;
end. 支持~~支持!! 原帖由 caterpilla 于 2006-8-2 11:05 发表
感到使用VB等语言的兄弟调用这些现成的算法比较麻烦,特写个DLL,给大家调用,呵呵。。。。。。。。。
MIME也就是BASE64,其它的就不多说了。。。。。。。。
下面的源码是VB.NET写的,把其中的源码拷贝到VB6中也 ...
提供一个封装MIME,XXE,UUE和MD5变换的DLL,附VB和DELPHI调用示例源码
好东西,感谢分享 好东西,谢谢分享 DLL虽好,但是不过是个黑盒子,可不可以把源码发上来?期待ing! 谢谢楼主分享 原帖由 wofan 于 2006-10-10 08:25 发表
DLL虽好,但是不过是个黑盒子,可不可以把源码发上来?期待ing!
源码与以前发的工具贴中类似,请查一下我的贴子。用DELPHI控件实现的,难度不大。 顶~~~~
页:
[1]
2