2 abc1234679 abc1234679 于 2016.05.09 16:10 提问

一个关于VB设计注册机的问题

图片说明
照其他资料写了分别为:”获取计算机某码“、”利用计算机某码生成注册码“、”利用注册码登录主程序“这三个程序,那么,下面怎么做?如何写一个主机端,主机端可以为注册码:“设置时间限制”、“给注册码加时间”、“通过我的主机端能看到客户端注册码使用信息“这三类?
求师傅指点迷津 【提供一下思路也可以】

3个回答

pay21
pay21   2016.05.09 17:45
已采纳

MD5("软件名称和版本号"+"软件合法使用的时间和地点信息"+"软件作者的身份证号"+"软件卖出的价格"+"使用者的身份证号"+"使用者的手机号"+"一个只有软件作者知道的密码")
VB code
Option Explicit
Private Declare Function CryptAcquireContext Lib "advapi32.dll" Alias "CryptAcquireContextA" (ByRef phProv As Long, ByVal pszContainer As String, ByVal pszProvider As String, ByVal dwProvType As Long, ByVal dwFlags As Long) As Long
Private Declare Function CryptReleaseContext Lib "advapi32.dll" (ByVal hProv As Long, ByVal dwFlags As Long) As Long
Private Declare Function CryptCreateHash Lib "advapi32.dll" (ByVal hProv As Long, ByVal Algid As Long, ByVal hKey As Long, ByVal dwFlags As Long, ByRef phHash As Long) As Long
Private Declare Function CryptDestroyHash Lib "advapi32.dll" (ByVal hHash As Long) As Long
Private Declare Function CryptHashData Lib "advapi32.dll" (ByVal hHash As Long, pbData As Any, ByVal dwDataLen As Long, ByVal dwFlags As Long) As Long
Private Declare Function CryptGetHashParam Lib "advapi32.dll" (ByVal hHash As Long, ByVal dwParam As Long, pbData As Any, pdwDataLen As Long, ByVal dwFlags As Long) As Long
Private Const HP_HASHVAL = 2
Private Const HP_HASHSIZE = 4
Private Const PROV_RSA_FULL = 1
Private Const CRYPT_NEWKEYSET = &H8
Private Const ALG_CLASS_HASH = 32768
Private Const ALG_TYPE_ANY = 0
Private Const ALG_SID_MD2 = 1
Private Const ALG_SID_MD4 = 2
Private Const ALG_SID_MD5 = 3
Private Const ALG_SID_SHA1 = 4
Enum HashAlgorithm
MD2 = ALG_CLASS_HASH Or ALG_TYPE_ANY Or ALG_SID_MD2
MD4 = ALG_CLASS_HASH Or ALG_TYPE_ANY Or ALG_SID_MD4
MD5 = ALG_CLASS_HASH Or ALG_TYPE_ANY Or ALG_SID_MD5
SHA1 = ALG_CLASS_HASH Or ALG_TYPE_ANY Or ALG_SID_SHA1
End Enum

Public Function HashString(ByVal Str As String, Optional ByVal Algorithm As HashAlgorithm = MD5) As String
Dim hCtx As Long
Dim hHash As Long
Dim lRes As Long
Dim lLen As Long
Dim lIdx As Long
Dim abData() As Byte

lRes = CryptAcquireContext(hCtx, vbNullString, vbNullString, PROV_RSA_FULL, 0)
If lRes <> 0 Then
lRes = CryptCreateHash(hCtx, Algorithm, 0, 0, hHash)
If lRes <> 0 Then
lRes = CryptHashData(hHash, ByVal Str, Len(Str), 0)
If lRes <> 0 Then
lRes = CryptGetHashParam(hHash, HP_HASHSIZE, lLen, 4, 0)
If lRes <> 0 Then
ReDim abData(0 To lLen - 1)
lRes = CryptGetHashParam(hHash, HP_HASHVAL, abData(0), lLen, 0)
If lRes <> 0 Then
For lIdx = 0 To UBound(abData)
HashString = HashString & Right$("0" & Hex$(abData(lIdx)), 2)
Next
End If
End If
End If
CryptDestroyHash hHash
End If
End If
CryptReleaseContext hCtx, 0
If lRes = 0 Then Err.Raise Err.LastDllError
End Function
【转载】

abc1234679
abc1234679 注释一下啊大哥
一年多之前 回复
a510835147
a510835147   2016.05.09 17:15

将这些信息存入数据库就可以了啊

abc1234679
abc1234679 具体怎么做,数据库建立在主机端,客户端登录后是不是得进入我的数据库查询后返回数据
一年多之前 回复
xianfajushi
xianfajushi   2016.05.09 19:12

大部分不需什么注释,鼠标指向查看函数解释可看个大概.

xianfajushi
xianfajushi 故中华先人智慧名言:事缓则圆。意思是有充分的时间去思考理解。
一年多之前 回复
xianfajushi
xianfajushi 回复abc1234679: 遇事切勿急,越急越无主见,无中华先人智慧名言:事缓则圆。意思是有充分的时间去思考理解。
一年多之前 回复
abc1234679
abc1234679 关键是我不知道怎么操作啊,添加什么控件
一年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!