# (#Not piracy) Keygen algorithm question

Page 1 of 1

## 7 Replies - 646 Views - Last Post: 13 April 2012 - 05:18 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=275124&amp;s=a448f5a0b8e20d84008912fba25480de&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 mikkchl

Reputation: 0
• Posts: 5
• Joined: 13-April 12

# (#Not piracy) Keygen algorithm question

Posted 13 April 2012 - 02:33 PM

Hello guys.
I have for a few weeks try'ed to make a keygen. I have a working code, but i think that it looks waaay to complicated. Can you please come with examples on how to do it in an easy'er way?

```Public Class Form1
Function generate()
beg:0
Dim serial(5) As String
Dim snothing(5) As Single
Do
Randomize()
serial(1) = Int(Rnd() * 10)
serial(3) = Int(Rnd() * 10)
snothing(1) = serial(1)
snothing(3) = serial(3)
Loop Until (snothing(1) + 5 + (snothing(3) * 2) = "28")
Do
Randomize()
serial(2) = Int(Rnd() * 10)
serial(5) = Int(Rnd() * 10)
snothing(2) = serial(2)
snothing(5) = serial(5)
Loop Until (snothing(2) + snothing(5) + 4 = "14")
Do
Randomize()
serial(4) = Int(Rnd() * 10)
snothing(4) = serial(4)
Loop Until (snothing(4) * 2 = "12")
Dim s As String
s = (snothing(1) & snothing(2) & snothing(3) & snothing(4) & snothing(5))
Return s
End Function

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = generate()
End Sub
End Class

```

Is This A Good Question/Topic? 0

## Replies To: (#Not piracy) Keygen algorithm question

• MrCupOfT

Reputation: 1998
• Posts: 8,808
• Joined: 29-May 08

## Re: (#Not piracy) Keygen algorithm question

Posted 13 April 2012 - 02:43 PM

Do you know you're doing thing in a very VB6 style? .Net has made thing a lot easier.

Random Numbers

### #3 mikkchl

Reputation: 0
• Posts: 5
• Joined: 13-April 12

## Re: (#Not piracy) Keygen algorithm question

Posted 13 April 2012 - 02:46 PM

I like "int(rnd() * %number%)" xD

• MrCupOfT

Reputation: 1998
• Posts: 8,808
• Joined: 29-May 08

## Re: (#Not piracy) Keygen algorithm question

Posted 13 April 2012 - 02:55 PM

Try that with Option Strict On

Can be better than the following?
```Public Module MyRandomStuff
Dim rng As New Random

Public Function GetRandomDigit() As Integer
Return rng.Next(0,10) ' pick an Integer between 0(inclusive) and 10(exclusive)'
End Function
End Module

```

As it much easier to read and understand the context of what the code is doing.

• MrCupOfT

Reputation: 1998
• Posts: 8,808
• Joined: 29-May 08

## Re: (#Not piracy) Keygen algorithm question

Posted 13 April 2012 - 03:22 PM

Why not simplify the following
```
Do
Randomize()
serial(4) = Int(Rnd() * 10)
snothing(4) = serial(4)
Loop Until (snothing(4) * 2 = "12")

```

to
```snothing(4)=6

```

### #6 mikkchl

Reputation: 0
• Posts: 5
• Joined: 13-April 12

## Re: (#Not piracy) Keygen algorithm question

Posted 13 April 2012 - 03:30 PM

I'm not asking how to shorten my code or anything like that. I only put the code in so you could see that I've try'ed myself. I want to know another way to make a keygen. I think my way i waay to complicated and dumb.

### #7 _HAWK_

• Master(Of Foo)

Reputation: 966
• Posts: 3,721
• Joined: 02-July 08

## Re: (#Not piracy) Keygen algorithm question

Posted 13 April 2012 - 03:46 PM

Key Gen!

### #8 mikkchl

Reputation: 0
• Posts: 5
• Joined: 13-April 12

## Re: (#Not piracy) Keygen algorithm question

Posted 13 April 2012 - 05:18 PM

I get the idea, but my first thought was that it would be very easy to guess, but thanks anyways.
Many weeks ago did i make a more advanced system, however i didn't finished it.
The idea was that a serial would be converted into numbers that should be consistent to an algorithm
the numbers were converted to text which(if the serial was true) were an aes password.

Here's the code:
```Function totalrand(ByVal s As String)
Dim first() As String = {"\$", "%", "#", "@", "!", "*", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "?", ";", ":", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "^", "&"}
'3,1,23,43,30,44,46,47,48,50,1
'@%q?x;ABCE%
Dim rndIndex As Integer = s
Dim test As String
test = (first(rndIndex))
Return test
End Function

'Nedestående funktion virker ikke!
Function checkkey()
Dim keycheck As String = TextBox1.Text
Dim tal1 As String = -1
Dim tal2 As String = 25
Do
tal1 = (tal1 + 1)
tal2 = (tal2 - 1)
If keycheck.Substring(tal1, 1) + keycheck.Substring(tal2, 1) = "2" Then
Else
End If
Loop Until tal1 = 12 And tal2 = 12
Return tal1
End Function

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim s As String
s = TextBox1.Text
s = s.ToUpper.Replace("9", "4")
s = s.ToUpper.Replace("0", "9")
s = s.ToUpper.Replace("5", "7")
s = s.ToUpper.Replace("2", "5")
s = s.ToUpper.Replace("X", "1")
s = s.ToUpper.Replace("A", "2")
s = s.ToUpper.Replace("U", "3")
s = s.ToUpper.Replace("H", "6")
s = s.ToUpper.Replace("Z", "8")
s = s.ToUpper.Replace("O", "0")
s = s.ToUpper.Replace("-", "")
TextBox1.Text = s
Dim serial(5) As String
serial(1) = TextBox1.Text.Substring(0, 1)
serial(2) = TextBox1.Text.Substring(1, 1)
serial(3) = TextBox1.Text.Substring(2, 1)
serial(4) = TextBox1.Text.Substring(3, 1)
serial(5) = TextBox1.Text.Substring(4, 1)
Dim resultat(5) As Single
resultat(1) = serial(1)
resultat(2) = serial(2)
resultat(3) = serial(3)
resultat(4) = serial(4)
resultat(5) = serial(5)
'If resultat(1) + 5 + (resultat(3) * 2) = "28" Then
'If resultat(2) + resultat(5) + 4 = "14" Then
'If resultat(4) * 2 = "12" Then
'3,1,23,43,30,44,46,47,48,50,1
TextBox2.Text = TextBox2.Text & totalrand(resultat(1) + (resultat(3) / 2))
TextBox2.Text = TextBox2.Text & totalrand(resultat(2) + resultat(5) + 4)
TextBox2.Text = TextBox2.Text & totalrand(resultat(4) * 2)
TextBox1.Text = TextBox2.Text
'@%abce%
TextBox2.Clear()
Exit Sub
'End If
'End If
'End If
MsgBox("Wrong serial")
Catch
MsgBox("Wrong serial")
End Try
End Sub
```