首页
社区
课程
招聘
[分享]提供一个封装MIME,XXE,UUE和MD5变换的DLL,附VB和DELPHI调用示例源码
发表于: 2006-9-12 08:23 5143

[分享]提供一个封装MIME,XXE,UUE和MD5变换的DLL,附VB和DELPHI调用示例源码

vxin 活跃值
10
2006-9-12 08:23
5143
转贴:

感到使用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

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

收藏
免费 0
支持
分享
最新回复 (5)
雪    币: 372
活跃值: (31)
能力值: ( LV12,RANK:410 )
在线值:
发帖
回帖
粉丝
2


附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.
上传的附件:
2006-9-12 08:24
0
雪    币: 218
活跃值: (40)
能力值: ( LV4,RANK:50 )
在线值:
发帖
回帖
粉丝
3
谢谢楼主MM,可否交个朋友,这个东西对我很有帮助。

QQ: 64100817

E-mail: nnscccn@yahoo.com.cn
2006-9-15 11:24
0
雪    币: 7325
活跃值: (3803)
能力值: (RANK:1130 )
在线值:
发帖
回帖
粉丝
4
最初由 nnscccn 发布
谢谢楼主MM,可否交个朋友,这个东西对我很有帮助。

QQ: 64100817

E-mail: nnscccn@yahoo.com.cn


楼主是GG
2006-9-17 22:45
0
雪    币: 207
活跃值: (10)
能力值: ( LV4,RANK:50 )
在线值:
发帖
回帖
粉丝
5
呵呵,谢谢转贴。。。。。。
2006-10-19 15:25
0
雪    币: 390
活跃值: (707)
能力值: ( LV12,RANK:650 )
在线值:
发帖
回帖
粉丝
6
这种东西,即使是代码,也是一搜就有。lz还是老老实实放源代码的好啊
2006-10-20 08:27
0
游客
登录 | 注册 方可回帖
返回
//