Imports System.IO Imports System.Text Imports System.Security.Cryptography Public Class registerMe Private serial As String = "xxx" Private validserial As String = "QQHP7R-624F5T-7M39ZA-JWGETN-1QQ1BS-DD" Private Sub Registerbtn_Click(sender As Object, e As EventArgs) Handles Registerbtn.Click serial = Serialtxtbx.Text 'validate serial If serial = validserial Then MessageBox.Show("Welcome! Serial accepted", "AccountEditor :: Licensing", MessageBoxButtons.OK, MessageBoxIcon.Information) IO.File.WriteAllText("license.pub", Encrypt(serial & vbTab & "04.10.2060" & vbTab & My.Computer.Name)) LicenseCheck() Else MessageBox.Show("Serial is not valid", "AccountEditor :: Licensing", MessageBoxButtons.OK, MessageBoxIcon.Error) End If End Sub Private Function Encrypt(ByVal strText As String) As String Dim strEncrKey As String = "c8YXEft&+fMs@]ntv2!JyUuFs[#xgXek" Dim byKey() As Byte = {} Dim IV() As Byte = {&H33, &H62, &H57, &H33, &H23, &H40, &H6A, &H75, &H72, &H5B, &H5F, &H42, &H50, &H55, &H76, &H73} Try byKey = System.Text.Encoding.UTF8.GetBytes(strEncrKey.Substring(0, 16)) Dim rijndael As New RijndaelManaged() Dim inputByteArray() As Byte = Encoding.UTF8.GetBytes(strText) Dim ms As New MemoryStream() Dim cs As New CryptoStream(ms, rijndael.CreateEncryptor(byKey, IV), CryptoStreamMode.Write) cs.Write(inputByteArray, 0, inputByteArray.Length) cs.FlushFinalBlock() Return Convert.ToBase64String(ms.ToArray()) Catch ex As Exception Return ex.Message End Try End Function 'The function used to decrypt the text Private Function Decrypt(ByVal strText As String) As String Dim sDecrKey As String = "c8YXEft&+fMs@]ntv2!JyUuFs[#xgXek" Dim byKey() As Byte = {} Dim IV() As Byte = {&H33, &H62, &H57, &H33, &H23, &H40, &H6A, &H75, &H72, &H5B, &H5F, &H42, &H50, &H55, &H76, &H73} Dim inputByteArray(strText.Length) As Byte Try byKey = System.Text.Encoding.UTF8.GetBytes(sDecrKey.Substring(0, 16)) Dim rijn As New RijndaelManaged() inputByteArray = Convert.FromBase64String(strText) Dim ms As New MemoryStream() Dim cs As New CryptoStream(ms, rijn.CreateDecryptor(byKey, IV), CryptoStreamMode.Write) cs.Write(inputByteArray, 0, inputByteArray.Length) cs.FlushFinalBlock() Dim encoding As System.Text.Encoding = System.Text.Encoding.UTF8 Return encoding.GetString(ms.ToArray()) Catch ex As Exception Return ex.Message End Try End Function Private Sub registerMe_Load(sender As Object, e As EventArgs) Handles MyBase.Load LicenseCheck() End Sub Private Sub LicenseCheck() If File.Exists("license.pub") Then Try serial = Decrypt(IO.File.ReadAllText("license.pub")) Dim SerialDate As DateTime = serial.Split(vbTab)(1) If serial.Split(vbTab)(0) = validserial Then If DateTime.Compare(SerialDate.ToUniversalTime, DateTime.Now.Date.ToUniversalTime) = 1 Then If My.Computer.Name = serial.Split(vbTab)(2) Then Me.Hide() selectAccount.ShowDialog() Environment.Exit(0) Else Throw New Exception("Seems like your want to cheat the licensing system! Please delete license.pub and re-register this tool!") End If Else Throw New Exception("Serial expired at " & serial.Split(vbTab)(1)) End If Else Throw New Exception("Serial is not valid") End If Catch ex As Exception MessageBox.Show(ex.Message, "AccountEditor :: Licensing", MessageBoxButtons.OK, MessageBoxIcon.Error) Environment.Exit(0) End Try End If End Sub End Class