Posted By

simoncoder on 06/14/17


Tagged

crypt guid keycode REGKEY


Versions (?)

Microsoft Type Registration Key


 / Published in: VB.NET
 

This function will create a REG Key XXXXX-XXXX-XXXXX where the first 5 numbers always add up to 10, the second set always adds up to 15 and the final set is always random.

  1. Function cypt()
  2.  
  3. Dim a1, a2 As Integer
  4. Dim va, vb, vc, vd, ve As Integer
  5. Do Until Val(va) + Val(vb) + Val(vc) + Val(vd) + Val(ve) = 10
  6. va = CInt(Int((9 * Rnd()) + 1))
  7. vb = CInt(Int((9 * Rnd()) + 1))
  8. vc = CInt(Int((9 * Rnd()) + 1))
  9. vd = CInt(Int((9 * Rnd()) + 1))
  10. ve = CInt(Int((9 * Rnd()) + 1))
  11.  
  12. a1 = va & vb & vc & vd & ve
  13. Loop
  14.  
  15. Dim v1, v2, v3, v4 As Integer
  16. Do Until Val(v1) + Val(v2) + Val(v3) + Val(v4) = 15
  17. v1 = CInt(Int((9 * Rnd()) + 1))
  18. v2 = CInt(Int((9 * Rnd()) + 1))
  19. v3 = CInt(Int((9 * Rnd()) + 1))
  20. v4 = CInt(Int((9 * Rnd()) + 1))
  21.  
  22. a2 = v1 & v2 & v3 & v4
  23. Loop
  24.  
  25. Return a1 & "-" & a2 & "-" & grs(5)
  26.  
  27. End Function
  28.  
  29.  
  30. Function grs(ByRef length As Integer) As String
  31. Randomize()
  32. Dim ac As String
  33. ac = "0123456789"
  34.  
  35. Dim i As Integer
  36. For i = 1 To length
  37. grs = grs & Mid$(ac, Int(Rnd() * Len(ac) + 1), 1)
  38. Next
  39. End Function
  40.  
  41. Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
  42. 'Add a BUTTON and a TEXTBOX
  43. tx1.Clear() 'Clears the textbox
  44. tx1.Text = cypt()
  45. End Sub

Report this snippet  

You need to login to post a comment.