Advertisement
Guest User

Untitled

a guest
Jan 20th, 2011
3,279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   Public Function CreerID() As String
  2.  
  3.         'on commence par ouvrir les clés
  4.        Dim cléPID As RegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion", False)
  5.         Dim cléGUID As RegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Cryptography", False)
  6.  
  7.         'On enlève les tirets, pour avoir un seul code composé de chiffres/lettres uniquement
  8.        Dim IDProduit As String = Replace(cléPID.GetValue("ProductId"), "-", "")
  9.         Dim GUID As String = Replace(cléGUID.GetValue("MachineGUID"), "-", "")
  10.  
  11.         Dim tampon As String = ""
  12.         'on renverse les chaines..Juste pour rendre notre système de clé unique
  13.        Dim strPID As String = StrReverse(IDProduit)
  14.         Dim strGUID As String = StrReverse(GUID)
  15.  
  16.         'On va mixer le tout pour obtenir un code constant et vraiment introuvable
  17.  
  18.         For i = 1 To IDProduit.Length 'pour chaque caractère du code
  19.            tampon = tampon & Hex((Asc(Mid(strPID, i, 2)) Xor 15) Xor 100) 'on le convertit en quelque chose d'aléatoire
  20.        Next i
  21.  
  22.         'tampon est donc maintenant notre partie "IDProduit" finale
  23.  
  24.         'On fait pareil pour le GUID
  25.        For x = 1 To GUID.Length
  26.             tampon = tampon & Hex((Asc(Mid(strGUID, x, 2)) Xor 12) Xor 100)
  27.         Next x
  28.  
  29.         Dim IDHardware As String = tampon  'le code final qui rejoint les deux parties
  30.        Return IDHardware
  31.  
  32.     End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement