[ActiveLock-Development] CVS: activelock2/src IActiveLock.cls,1.8,1.9
Brought to you by:
ialkan
From: Thanh H. T. <th...@us...> - 2003-08-04 11:54:11
|
Update of /cvsroot/activelock/activelock2/src In directory sc8-pr-cvs1:/tmp/cvs-serv17677 Modified Files: IActiveLock.cls Log Message: Added vbdox for key generator and registration process. Index: IActiveLock.cls =================================================================== RCS file: /cvsroot/activelock/activelock2/src/IActiveLock.cls,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- IActiveLock.cls 3 Aug 2003 09:01:04 -0000 1.8 +++ IActiveLock.cls 4 Aug 2003 11:54:08 -0000 1.9 @@ -163,6 +163,87 @@ ' End Function ' </pre> ' +' <p>Generating registration request code from the user application. +' <pre> +' ' Generate Request code +' Dim strReq As String, strLock As String +' strLock = MyActiveLock.LockCode() +' ' Combine with user name +' strReq = strLock & vbLf & txtUser +' ' base-64 encode the request +' Dim strReq2 As String +' strReq2 = ActiveLock2.Base64Encode(strReq) +' ' strReq2 now contains the request code to be sent to the vendor for activation. +' </pre> +' +' <p>Key Generator functionality - generating license key for a request code. +' <pre> +' ' First, take request code and decode it. +' Dim strReq As String +' strReq = ActiveLock2.Base64Decode(txtReqCodeIn) +' ' strReq now contains the {LockCode + vbLf + User} string +' Dim strLock$, strUser$ +' +' ' Get Lock and user from request code +' Dim Index% +' Index = InStr(1, strReq, vbLf) +' If Index <= 0 Then Exit Sub +' +' strLock = Left(strReq, Index - 1) +' strUser = Mid$(strReq, Index + 1) +' strUser = TrimNulls(strUser) +' +' ' Compute expiration date for a 1-year license +' Dim strExpire$ +' strExpire = Format$(Now + 365, "YYYY/MM/DD") +' +' ' registration date +' Dim strRegDate As String +' strRegDate = Format(Now(), "yyyy/mm/dd") +' Dim strEncrypted As String +' +' ' Use the same encryption routine as ActiveLockEventSink_ValidateValue() event to encrypt the key +' ActiveLockEventSink_ValidateValue strRegDate, strEncrypted +' +' ' hash it +' strEncrypted = ActiveLock2.MD5Hash(strEncrypted) +' +' Dim Lic As ProductLicense +' Set Lic = ActiveLock2.CreateProductLicense(txtName, txtSoftwareCodePub, _ +' txtVersion, MyActiveLock.LockType, MyActiveLock.LicenseType, strUser, strExpire, , strRegDate, strEncrypted) +' Dim strLic As String +' ' encrypt Product license using LockCode +' strLic = MyActiveLock.LockCode(Lic) +' ' Sign it +' Dim strSig As String +' strSig = ActiveLock2.RSASign(PUB_KEY, PRIV_KEY, strLic) +' ' Create liberation key. This will be a base-64 encoded string of the whole license. +' Dim strLicKey As String +' strLicKey = ActiveLock2.Base64Encode(strSig) +' ' update Lic with license key +' Lic.LicenseKey = strLicKey +' ' Serialize it into a formatted string +' Dim strLibKey As String +' Lic.Save strLibKey +' Debug.Print "This is your liberation key: " & strLibKey +' </pre> +' +' <p>Key Registration functionality - register using a liberation key. +' <pre> +' On Error GoTo ErrHandler +' ' Register this key +' Dim Lic As New ActiveLock2.ProductLicense +' ' txtLibKey contains the liberation key entered by the user. +' ' This key could have be sent via an email to the user or a program that automatically +' ' requests the key from a registration website. +' ' Load up the license txtLibKey +' Lic.Load txtLibKey +' MyActiveLock.Register Lic +' MsgBox "Registration successful!" +' Exit Sub +'ErrHandler: +' MsgBox Err.Number & ": " & Err.Description +' </pre> ' ' @author th...@us... ' @version 2.0.0 |