紧急:高手看看这个Des加密函数如何调用

罗平 2009-05-11 12:34:01
紧急:高手看看这个Des加密函数如何调用

在网上下载一个VB 写的Des加密模块,不知道如何调用,(源代码:http://www.qwin.net/vbdes.txt),函数形式如下:

加密:
Public Sub DES_Encode(ByRef sCode() As Byte, ByVal sKey As String, ByRef bReturn() As Byte)

解密:
Public Sub DES_Decode(ByRef sCode() As Byte, ByVal sKey As String, ByRef bReturn() As Byte)

调用程序如下:

Private Sub Command10_Click()
Dim StrSource() As Byte
Dim StrDest() As Byte
Dim StrJiemi() As Byte
Dim StrKey As String

StrKey = "12345678" '密钥
StrSource = StrConv("待加密文字", vbFromUnicode)
Call DES_Encode(StrSource, StrKey, StrDest)
MsgBox StrConv(StrDest, vbUnicode) '加密后
Call DES_Decode(StrDest, StrKey, StrJiemi)
MsgBox StrConv(StrJiemi, vbUnicode) '解密后
End Sub

总是无法调用,加密或解密,结果都是空。
...全文
140 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
罗平 2009-05-12
  • 打赏
  • 举报
回复
谢谢 Chen8013,果然可以了。
舉杯邀明月 2009-05-11
  • 打赏
  • 举报
回复
新建一个工程,添加一个窗体、一个类模块。
把那个文本文件中的内容粘贴到类模块中,并且把类名更改为:claDES

在 Form 中添加一个按钮,粘贴下面的代码:
Option Explicit

Private Sub Command1_Click()

Const strKey = "123456789"
Dim objDES As New claDES
Dim arrSour() As Byte, arrBuff() As Byte, arrTest() As Byte
Dim i&

ReDim arrSour(15)
For i = 0 To 15: arrSour(i) = i * 3: Next
Debug.Print "Sour data:"
For i = 0 To 15
Debug.Print i, Hex$(arrSour(i))
Next
objDES.DES_Encode arrSour, strKey, arrBuff
i = UBound(arrBuff)
Debug.Print "EnCode >>>> "; i + 1; "Byte."
For i = 0 To i
Debug.Print i, Hex$(arrBuff(i))
Next
objDES.DES_Decode arrBuff, strKey, arrTest
i = UBound(arrTest)
Debug.Print "DeCode >>>> "; i + 1; "Byte."
For i = 0 To i
Debug.Print i, Hex$(arrTest(i))
Next

End Sub

罗平 2009-05-11
  • 打赏
  • 举报
回复
都不行啊。
罗平 2009-05-11
  • 打赏
  • 举报
回复
没有人帮忙看看吗?
liuxu2559 2009-05-11
  • 打赏
  • 举报
回复
bReturn数组没有声明空间吧.
dim bReturn(7) as Byte
或在Des加密中
Redim bReturn(7) as Byte
of123 2009-05-11
  • 打赏
  • 举报
回复
试试:
Dim StrSource(7) As Byte
Dim StrDest(7) As Byte
Dim StrJiemi(7) As Byte

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧