Terkadang ketika kita ingin mengistall sebuah Aplikasi pada komputer, Anda dimainta untuk memasukan KeyGen atau Generator Serial Number sebagai kode kunci untuk mengistall aplikasi tersebut yang tandanya bahwa Anda telah me-Registrasi secara sah.
Dalam postingan kali ini Admin akan berbagi sebuah kode cara membuat KeyGen dengan menggunakan visual basic 6.0 (vb6).
Output |
Berikut adalah langkah-langkah Cara Membuat KeyGen Dengan Visual Basic 6.0 (vb6) dengan mudah :
- Buka Form VB6 Standar EXE
- Pada From1 tanamkan 2 buah Label, 2 buah TextBox dan 1 CommanButton
- Tambahkan juga 1 buah Module pada Form1
- Desainlah form seperti gambar dibawah ini :
Desain Form |
Option Explicit
Function KeyGen(kNamev As Variant, kPass As String, kType As Integer) As String
On Error Resume Next
Dim cTable(512) As Integer
Dim nKeys(16) As Integer
Dim s0(512) As Integer
Dim nArray(16) As Integer
Dim pArray(16) As Integer
Dim n As Integer
Dim nPtr As Integer
Dim cPtr As Integer
Dim cFlip As Boolean
Dim sIni As Integer
Dim temp As Integer
Dim rtn As Integer
Dim gKey As String
Dim nLen As Integer
Dim pLen As Integer
Dim kPtr As Integer
Dim sPtr As Integer
Dim nOffset As Integer
Dim pOffset As Integer
Dim tOffset As Integer
Dim KeySize As Integer
Const nXor As Integer = 18
Const pXor As Integer = 25
Const cLw As Integer = 65
Const nLw As Integer = 48
Const sOffset As Integer = 0
Dim VarType As String
Dim kName As String
Dim AryCtl As Integer
Dim AryCtrl As Control
VarType = TypeName(kNamev)
Select Case VarType
Case "String"
kName = kNamev
Case "TextBox"
kName = kNamev.Text
Case "Object"
For Each AryCtrl In kNamev
If AryCtrl.Text <> "" Then
kName = kName & AryCtrl.Text & "|"
End If
Next
kName = Left(kName, Len(kName) - 1)
Case "String()"
For AryCtl = LBound(kNamev) To UBound(kNamev)
If kNamev(AryCtl) <> "" Then
kName = kName & kNamev(AryCtl) & "|"
End If
Next
kName = Left(kName, Len(kName) - 1)
Case Else
MsgBox VarType & " is an unsupported type to be passed to KeyGen"
End Select
'****************************************************************************
nLen = Len(kName)
pLen = Len(kPass)
'password xor keys ** change to make keygen unique **
nKeys(1) = 46
nKeys(2) = 89
nKeys(3) = 142
nKeys(4) = 63
nKeys(5) = 231
nKeys(6) = 32
nKeys(7) = 129
nKeys(8) = 51
nKeys(9) = 28
nKeys(10) = 97
nKeys(11) = 248
nKeys(12) = 41
nKeys(13) = 136
nKeys(14) = 53
nKeys(15) = 78
nKeys(16) = 164
sIni = 0
'set s boxes
For n = 0 To 512
s0(n) = n
Next n
For n = 0 To 512
sIni = (sOffset + sIni + n) Mod 256
temp = s0(n)
s0(n) = s0(sIni)
s0(sIni) = temp
Next n
If kType = 1 Then '(numeric)
nPtr = 0
KeySize = 16
gKey = String(16, " ")
For n = 0 To 512
cTable(s0(n)) = (nLw + (nPtr))
nPtr = nPtr + 1
If nPtr = 10 Then nPtr = 0
Next n
ElseIf kType = 2 Then '(alphanumeric)
nPtr = 0
cPtr = 0
KeySize = 16
gKey = String(16, " ")
cFlip = False
For n = 0 To 512
If cFlip Then
cTable(s0(n)) = (nLw + nPtr)
nPtr = nPtr + 1
If nPtr = 10 Then nPtr = 0
cFlip = False
Else
cTable(s0(n)) = (cLw + cPtr)
cPtr = cPtr + 1
If cPtr = 26 Then cPtr = 0
cFlip = True
End If
Next n
Else '(hex)
KeySize = 8
gKey = String(19, " ")
End If
kPtr = 1
For n = 1 To nLen 'name
nArray(kPtr) = nArray(kPtr) + Asc(Mid(kName, n, 1)) Xor nXor
nOffset = nOffset + nArray(kPtr)
kPtr = kPtr + 1
If kPtr = 9 Then kPtr = 1
Next n
For n = 1 To pLen 'password
pArray(kPtr) = pArray(kPtr) + Asc(Mid(kPass, n, 1)) Xor pXor
pOffset = pOffset + pArray(kPtr)
kPtr = kPtr + 1
If kPtr = 9 Then kPtr = 1
Next n
tOffset = (nOffset + pOffset) Mod 512
kPtr = 1
sPtr = 1
For n = 1 To KeySize
pArray(n) = pArray(n) Xor nKeys(n)
rtn = Abs(((nArray(n) Xor pArray(n)) Mod 512) - tOffset)
If kType = 3 Then 'hex key
If rtn < 16 Then
Mid(gKey, kPtr, 2) = "0" & Hex(rtn)
Else
Mid(gKey, kPtr, 2) = Hex(rtn)
End If
If sPtr = 2 And kPtr < 18 Then
kPtr = kPtr + 1
Mid(gKey, kPtr + 1, 1) = "-"
End If
kPtr = kPtr + 2
sPtr = sPtr + 1
If sPtr = 3 Then sPtr = 1
Else 'numeric - alphanumeric key
Mid(gKey, n, 1) = Chr(cTable(rtn))
End If
Next
KeyGen = gKey
End Function
No comments:
Post a Comment