MD5 加密算法 VB 实现代码
虽然现在MD5 加密算法严格来讲已经不算安全,但一般小功能或公司内部使用应该足够了
Attribute VB_Name = "modMd5"
' MODULE: CMD5
'*******************************************************************************
Option Explicit
Public Const BITS_TO_A_BYTE As Long = 8
Public Const BYTES_TO_A_WORD As Long = 4
Public Const BITS_TO_A_WORD As Long = BYTES_TO_A_WORD * BITS_TO_A_BYTE
Public m_lOnBits(0 To 30) As Long
Public m_l2Power(0 To 30) As Long
Public Function MD5_Encrypt(ByVal sText As String) As String
MD5_Init
MD5_Encrypt = MD5(sText)
End Function
'*******************************************************************************
' Class_Initialize (SUB)
'
' DESCRIPTION:
' We will usually get quicker results by preparing arrays of bit patterns and
' powers of 2 ahead of time instead of calculating them every time, unless of
' course the methods are only ever getting called once per instantiation of the
' class.
'*******************************************************************************
Public Sub MD5_Init()
' Could have done this with a loop calculating each value, but simply
' assigning the values is quicker - BITS SET from RIGHT
m_lOnBits(0) = 1 ' 00000000000000000000000000000001
m_lOnBits(1) = 3 ' 00000000000000000000000000000011
m_lOnBits(2) = 7 ' 00000000000000000000000000000111
m_lOnBits(3) = 15 ' 00000000000000000000000000001111
m_lOnBits(4) = 31 ' 00000000000000000000000000011111
m_lOnBits(5) = 63 &nb
相关文档:
VB中 Replace 函数
描述
返回字符串,其中指定数目的某子字符串被替换为另一个子字符串。
语法
Replace(expression, find, replacewith[, compare[, count[, start]]])
Replace 函数的语法有以下参数:
参数 描述
expression 必选。字符串表达式,包含要替换的子字符串。
find 必选。被搜索的子字符串。
......
这一段大家编写程序很多时候都在使用API,它给我们带来了强大的功能.让我们非常惊喜.
但是我们在调试程序的时候有时候总会奔溃.这样很不方便.
其中有些是api惹的祸
使用api注意事项:
首先我说说我的观点.
1:Api是很多系统也在用.我们在设置参数时如果和系统的参数有冲突.就可能引起软件出错
2.api很多都是c语言编写的, ......
在很多 VB 的资料库书籍中,都会很完整的提到:如何由其他种类的文件中将资料导入资料库,但是却很少有书提到:如何将资料库中的资料,导出到各种不同的文件类型的文件中,连 VB 的 Help 中也是这样!
或许是大家都认为资料库主题的重点是在资料库本身吧!
但是,在实际的资料库程序运用中,却常常需要将资料库导出到各种 ......
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Private Const EWX_LOGOFF = 0
Private Const EWX_SHUTDOWN = 1
Private Const EWX_REBOOT = 2
Private Const EWX_FORCE = 4
Private closeTime As String
Sub AdjustTokenPrivilegesForNT()
......