| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 438 人关注过本帖
标题:求助,高手请进
只看楼主 加入收藏
yizhiduxiu
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2005-12-26
收藏
 问题点数:0 回复次数:0 
求助,高手请进

谁能帮我把这个vb程序用c++类进行封装吗,谢了 qq 105805019
Option Strict On
Option Explicit On

Imports System.Security.Cryptography

Public Class MD5
Public Shared Function MD5Hash(ByVal str As String) As String

Dim len As Integer = util.StrLen(str)
Dim buf(len - 1), buf2() As Byte
Dim i, c As Integer

util.S2B(str, buf, str.Length())

Dim Crypto As New MD5CryptoServiceProvider()
buf2 = Crypto.ComputeHash(buf)

MD5Hash = ""
For i = 0 To buf2.Length - 1

c = CType((buf2(i) And &HF0) / 16, Integer)
If c 〈 10 Then
c += 48
Else
c += 87
End If
MD5Hash += Chr(c)

c = buf2(i) And &HF
If c 〈 10 Then
c += 48
Else
c += 87
End If
MD5Hash += Chr(c)

Next

End Function

End Class


Public Shared Sub S2B(ByVal str As String, ByRef buf As Byte(), ByVal len As Integer)

Dim i, p, ch As Integer

p = 0
For i = 0 To len - 1
ch = Asc(str.Chars(i))
If ch 〉 126 Or ch 〈 0 Then
buf(p) = CType((ch And &HFF00) / 256, Byte)
p += 1
buf(p) = CType(ch And &HFF, Byte)
Else
buf(p) = CType(ch, Byte)
End If
p += 1
Next
End Sub

2005-12-30 17:53
快速回复:求助,高手请进
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015713 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved