Guest User

Untitled

a guest
Jul 15th, 2013
431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 5.14 KB | None | 0 0
  1. Private Sub frmMakeKeygen_Load(ByVal sender As Object, ByVal e As EventArgs)
  2.             Try
  3.                 Dim passPhrase As String = "kEyG3n^^@k3R"
  4.                 Dim saltValue As String = "*PasSalt^@!"
  5.                 Dim hashAlgorithm As String = "SHA1"
  6.                 Dim passwordIterations As Integer = 2
  7.                 Dim initVector As String = "@1B2c3D4e5F6g7H8"
  8.                 Dim keySize As Integer = &H100
  9.                 Dim path As String = (Application.StartupPath & "\Setting.dll")
  10.                 If File.Exists(path) Then
  11.                     Dim reader As StreamReader = Nothing
  12.                     reader = New StreamReader(path)
  13.                     Dim reader2 As New StringReader(RijndaelSimple.Decrypt(reader.ReadToEnd, passPhrase, saltValue, hashAlgorithm, passwordIterations, initVector, keySize))
  14.                     Me.dname = reader2.ReadLine
  15.                     Me.Key0 = reader2.ReadToEnd
  16.                 Else
  17.                     MsgBox("Setting.dll is missing! Please place the required file.", MsgBoxStyle.ApplicationModal, Nothing)
  18.                     ProjectData.EndApp
  19.                 End If
  20.             Catch exception1 As Exception
  21.                 ProjectData.SetProjectError(exception1)
  22.                 Dim exception As Exception = exception1
  23.                 MsgBox("Something went wrong! Please contact [email protected]", MsgBoxStyle.Information, "Error!")
  24.                 ProjectData.ClearProjectError
  25.             Finally
  26.                 Me.TextBox1.Text = Me.dname
  27.                 Me.Text = (Me.dname & " - Keygen")
  28.             End Try
  29.         End Sub
  30.  
  31. As fi folosit RandomLineFromFile
  32.  
  33.  Try
  34.                 Dim array As String() = Me.Key0.Split(Environment.NewLine.ToCharArray, StringSplitOptions.RemoveEmptyEntries)
  35.                 Me.ShuffleArray(array)
  36.                 Me.TextBox2.Text = array(0).ToString
  37.             Catch exception1 As Exception
  38.                 ProjectData.SetProjectError(exception1)
  39.                 Interaction.MsgBox(exception1.ToString, MsgBoxStyle.ApplicationModal, Nothing)
  40.                 Interaction.MsgBox("Something went wrong! Please contact [email protected]", MsgBoxStyle.Information, "Error!")
  41.                 ProjectData.ClearProjectError
  42.             End Try
  43.  
  44.  
  45. Imports Microsoft.VisualBasic.CompilerServices
  46. Imports System
  47. Imports System.IO
  48. Imports System.Security.Cryptography
  49. Imports System.Text
  50.  
  51. Namespace Keygen_Maker
  52.     <StandardModule> _
  53.     Friend NotInheritable Class Module1
  54.         ' Nested Types
  55.         Public Class RijndaelSimple
  56.             ' Methods
  57.             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
  58.                 Dim bytes As Byte() = Encoding.ASCII.GetBytes(initVector)
  59.                 Dim rgbSalt As Byte() = Encoding.ASCII.GetBytes(saltValue)
  60.                 Dim buffer As Byte() = Convert.FromBase64String(cipherText)
  61.                 Dim rgbKey As Byte() = New PasswordDeriveBytes(passPhrase, rgbSalt, hashAlgorithm, passwordIterations).GetBytes(CInt(Math.Round(CDbl((CDbl(keySize) / 8)))))
  62.                 Dim managed As New RijndaelManaged
  63.                 managed.Mode = CipherMode.CBC
  64.                 Dim transform As ICryptoTransform = managed.CreateDecryptor(rgbKey, bytes)
  65.                 Dim stream2 As New MemoryStream(buffer)
  66.                 Dim stream As New CryptoStream(stream2, transform, CryptoStreamMode.Read)
  67.                 Dim buffer4 As Byte() = New Byte((buffer.Length + 1)  - 1) {}
  68.                 Dim count As Integer = stream.Read(buffer4, 0, buffer4.Length)
  69.                 stream2.Close
  70.                 stream.Close
  71.                 Return Encoding.UTF8.GetString(buffer4, 0, count)
  72.             End Function
  73.  
  74.             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
  75.                 Dim bytes As Byte() = Encoding.ASCII.GetBytes(initVector)
  76.                 Dim rgbSalt As Byte() = Encoding.ASCII.GetBytes(saltValue)
  77.                 Dim buffer4 As Byte() = Encoding.UTF8.GetBytes(plainText)
  78.                 Dim rgbKey As Byte() = New PasswordDeriveBytes(passPhrase, rgbSalt, hashAlgorithm, passwordIterations).GetBytes(CInt(Math.Round(CDbl((CDbl(keySize) / 8)))))
  79.                 Dim managed As New RijndaelManaged
  80.                 managed.Mode = CipherMode.CBC
  81.                 Dim transform As ICryptoTransform = managed.CreateEncryptor(rgbKey, bytes)
  82.                 Dim stream2 As New MemoryStream
  83.                 Dim stream As New CryptoStream(stream2, transform, CryptoStreamMode.Write)
  84.                 stream.Write(buffer4, 0, buffer4.Length)
  85.                 stream.FlushFinalBlock
  86.                 Dim inArray As Byte() = stream2.ToArray
  87.                 stream2.Close
  88.                 stream.Close
  89.                 Return Convert.ToBase64String(inArray)
  90.             End Function
  91.  
  92.         End Class
  93.     End Class
  94. End Namespace
Advertisement
Add Comment
Please, Sign In to add comment