Hi,
I have a problem. I have been programming an activation type of security protection for my
software but i ran into problems when i try to generate an alphanumeric key with
conditions. i cant seem to be able to make the keys to be valid with the condition.
Basically i can get the 25 keys but all of them seem to be returning 1 (ones) instead of 0
(zero which what i want. below is my sample code may be someone can tell me what i am doing
wrong, by the way i did google, woogle,bing, bang, yahoo, yadoo etc but no go.
code: generate the keys
[CODE]
Public Function GenerateCode() As Object
Dim IntRnd As Object
Dim IntStep As Object
Dim StrName As Object
Dim IntNameLength As Object
Dim IntLength As Object
Dim StrInputString As Object
StrInputString = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"
IntLength = Len(StrInputString)
IntNameLength = 25
Randomize()
StrName = ""
For IntStep = 1 To IntNameLength
IntRnd = Int((IntLength * Rnd()) + 1)
StrName = StrName & Mid(StrInputString, IntRnd, 1)
Next
Return StrName
End Function
[/CODE]
code: here where i put the condition and here where it giving me hell
[CODE]
Public Function GetPID()
Dim pid As String = String.Empty
Dim digitalPid As Byte()
Dim sequenceNumber As Integer = 0
Dim upgradeFlag As Boolean = False
Dim isOem As Boolean = False
Dim oemID As String = Nothing
Dim builder As New StringBuilder(&H18, &H18)
digitalPid = New Byte(&H100 - 1) {}
Buffer.BlockCopy(BitConverter.GetBytes(digitalPid.Length), 0, digitalPid, 0, 4)
Dim num As Integer
dim key as string
redo1: key = generatecode()
num = setcon(key, con1, con2)
if num = 0 then
return key
else
goto redo1:
end if
End Function
[/CODE]
the damn thing keeps returning 1 instead of 0. I do know i can simply change to 1 and be
off the issue. but if is that easy to generate 1 then isnt it easy just to break it. oh yeah
the whole thing hangs when i generate the code???
if i loop it, its able to get a 0 but i cant take the key thats in the loop??
any idea or comment is much appreciated, i do not need the coding just the logic should do,
i should be able to find my way around...