Mylton
Member
- Local time
- Yesterday, 16:42
- Joined
- Aug 3, 2019
- Messages
- 124
Good morning
This function performs
'The GenerateLicense function receives the processor and motherboard numbers as input,
'calculate a SHA-256 hash from the concatenation of these numbers
' and returns the last 10 digits of that hash as a license.
'Used to generate a one-time license based on hardware specifications.
Function GerarLicense(NumeroProcessador As String, NumeroPlacaMae As String) As String
Dim key As String
Dim hash As String
' Concatenates the processor and motherboard numbers
key = Processor Number & Motherboard Number
' Create SHA-256 hash object
Dim objSHA256 As Object
Set objSHA256 = CreateObject("System.Security.Cryptography.SHA256Managed")
' Calculate the SHA-256 hash of the concatenated key
Dim bytes() As Byte
bytes = StrConv(key, vbFromUnicode)
bytes = objSHA256.ComputeHash_2(bytes)
' Convert the SHA-256 hash to a hexadecimal string
hash=""
Dim i As Integer
For i = LBound(bytes) To UBound(bytes)
hash = hash & Right("0" & Hex(bytes(i)), 2)
Next i
' Keep only the last 10 digits of the hash
GerarLicenca = Right(hash, 10)
End Function
I created a global variable declaration like this:
Option Compare Database
Public keyLicencaGlobal As String
When I try to use it to be demonstrated in a FrmAny text field with this code:
Private Sub Form_Load()
' Sets the value of the label to the value of the global variable
Me.txtChaveLicenca.value =chaveLicencaGlobal
End Sub
It is
Private Sub Form_Open(Cancel As Integer)
' Assign a value to the global variable
globalLicensekey = GlobalLicensekey
End Sub
The keyword LicencaGlobal appears.
I would like it to be shown what was stored in it.
Any tips...
Thanks
This function performs
'The GenerateLicense function receives the processor and motherboard numbers as input,
'calculate a SHA-256 hash from the concatenation of these numbers
' and returns the last 10 digits of that hash as a license.
'Used to generate a one-time license based on hardware specifications.
Function GerarLicense(NumeroProcessador As String, NumeroPlacaMae As String) As String
Dim key As String
Dim hash As String
' Concatenates the processor and motherboard numbers
key = Processor Number & Motherboard Number
' Create SHA-256 hash object
Dim objSHA256 As Object
Set objSHA256 = CreateObject("System.Security.Cryptography.SHA256Managed")
' Calculate the SHA-256 hash of the concatenated key
Dim bytes() As Byte
bytes = StrConv(key, vbFromUnicode)
bytes = objSHA256.ComputeHash_2(bytes)
' Convert the SHA-256 hash to a hexadecimal string
hash=""
Dim i As Integer
For i = LBound(bytes) To UBound(bytes)
hash = hash & Right("0" & Hex(bytes(i)), 2)
Next i
' Keep only the last 10 digits of the hash
GerarLicenca = Right(hash, 10)
End Function
I created a global variable declaration like this:
Option Compare Database
Public keyLicencaGlobal As String
When I try to use it to be demonstrated in a FrmAny text field with this code:
Private Sub Form_Load()
' Sets the value of the label to the value of the global variable
Me.txtChaveLicenca.value =chaveLicencaGlobal
End Sub
It is
Private Sub Form_Open(Cancel As Integer)
' Assign a value to the global variable
globalLicensekey = GlobalLicensekey
End Sub
The keyword LicencaGlobal appears.
I would like it to be shown what was stored in it.
Any tips...
Thanks