Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub frmMakeKeygen_Load(ByVal sender As Object, ByVal e As EventArgs)
- Try
- Dim passPhrase As String = "kEyG3n^^@k3R"
- Dim saltValue As String = "*PasSalt^@!"
- Dim hashAlgorithm As String = "SHA1"
- Dim passwordIterations As Integer = 2
- Dim initVector As String = "@1B2c3D4e5F6g7H8"
- Dim keySize As Integer = &H100
- Dim path As String = (Application.StartupPath & "\Setting.dll")
- If File.Exists(path) Then
- Dim reader As StreamReader = Nothing
- reader = New StreamReader(path)
- Dim reader2 As New StringReader(RijndaelSimple.Decrypt(reader.ReadToEnd, passPhrase, saltValue, hashAlgorithm, passwordIterations, initVector, keySize))
- Me.dname = reader2.ReadLine
- Me.Key0 = reader2.ReadToEnd
- Else
- MsgBox("Setting.dll is missing! Please place the required file.", MsgBoxStyle.ApplicationModal, Nothing)
- ProjectData.EndApp
- End If
- Catch exception1 As Exception
- ProjectData.SetProjectError(exception1)
- Dim exception As Exception = exception1
- ProjectData.ClearProjectError
- Finally
- Me.TextBox1.Text = Me.dname
- Me.Text = (Me.dname & " - Keygen")
- End Try
- End Sub
- As fi folosit RandomLineFromFile
- Try
- Dim array As String() = Me.Key0.Split(Environment.NewLine.ToCharArray, StringSplitOptions.RemoveEmptyEntries)
- Me.ShuffleArray(array)
- Me.TextBox2.Text = array(0).ToString
- Catch exception1 As Exception
- ProjectData.SetProjectError(exception1)
- Interaction.MsgBox(exception1.ToString, MsgBoxStyle.ApplicationModal, Nothing)
- Interaction.MsgBox("Something went wrong! Please contact [email protected]", MsgBoxStyle.Information, "Error!")
- ProjectData.ClearProjectError
- End Try
- Imports Microsoft.VisualBasic.CompilerServices
- Imports System
- Imports System.IO
- Imports System.Security.Cryptography
- Imports System.Text
- Namespace Keygen_Maker
- <StandardModule> _
- Friend NotInheritable Class Module1
- ' Nested Types
- Public Class RijndaelSimple
- ' Methods
- Public Shared Function Decrypt(ByVal cipherText As String, ByVal passPhrase As String, ByVal saltValue As String, ByVal hashAlgorithm As String, ByVal passwordIterations As Integer, ByVal initVector As String, ByVal keySize As Integer) As String
- Dim bytes As Byte() = Encoding.ASCII.GetBytes(initVector)
- Dim rgbSalt As Byte() = Encoding.ASCII.GetBytes(saltValue)
- Dim buffer As Byte() = Convert.FromBase64String(cipherText)
- Dim rgbKey As Byte() = New PasswordDeriveBytes(passPhrase, rgbSalt, hashAlgorithm, passwordIterations).GetBytes(CInt(Math.Round(CDbl((CDbl(keySize) / 8)))))
- Dim managed As New RijndaelManaged
- managed.Mode = CipherMode.CBC
- Dim transform As ICryptoTransform = managed.CreateDecryptor(rgbKey, bytes)
- Dim stream2 As New MemoryStream(buffer)
- Dim stream As New CryptoStream(stream2, transform, CryptoStreamMode.Read)
- Dim buffer4 As Byte() = New Byte((buffer.Length + 1) - 1) {}
- Dim count As Integer = stream.Read(buffer4, 0, buffer4.Length)
- stream2.Close
- stream.Close
- Return Encoding.UTF8.GetString(buffer4, 0, count)
- End Function
- Public Shared Function Encrypt(ByVal plainText As String, ByVal passPhrase As String, ByVal saltValue As String, ByVal hashAlgorithm As String, ByVal passwordIterations As Integer, ByVal initVector As String, ByVal keySize As Integer) As String
- Dim bytes As Byte() = Encoding.ASCII.GetBytes(initVector)
- Dim rgbSalt As Byte() = Encoding.ASCII.GetBytes(saltValue)
- Dim buffer4 As Byte() = Encoding.UTF8.GetBytes(plainText)
- Dim rgbKey As Byte() = New PasswordDeriveBytes(passPhrase, rgbSalt, hashAlgorithm, passwordIterations).GetBytes(CInt(Math.Round(CDbl((CDbl(keySize) / 8)))))
- Dim managed As New RijndaelManaged
- managed.Mode = CipherMode.CBC
- Dim transform As ICryptoTransform = managed.CreateEncryptor(rgbKey, bytes)
- Dim stream2 As New MemoryStream
- Dim stream As New CryptoStream(stream2, transform, CryptoStreamMode.Write)
- stream.Write(buffer4, 0, buffer4.Length)
- stream.FlushFinalBlock
- Dim inArray As Byte() = stream2.ToArray
- stream2.Close
- stream.Close
- Return Convert.ToBase64String(inArray)
- End Function
- End Class
- End Class
- End Namespace
Advertisement
Add Comment
Please, Sign In to add comment