Hi everybody;
Below code is my encyription algorithm that I use in my vb.net projects.
Here are couple of example outputs:
RealBlue : mLvmg4ntx2mSewxoYrwBPA==
B4A : ZOKsIfBqR05Kr1KAzZsDuA==
c@nb3@goo6p@ssw0rd : BzEPjMg87c28cPlf5WePfhYVKHBNB0lU6jGJ0o+3V0Y=
In THIS thread there is another one is already converted.
Can anyone help me converting this one also.
Thanks in advance.
Below code is my encyription algorithm that I use in my vb.net projects.
B4X:
Friend Shared Function EncryptPasswordMD5(ByVal plainText As String, ByVal p_strSaltValue As String) As String
Dim strReturn As String = String.Empty
Try
Dim initVectorBytes As Byte()
initVectorBytes = System.Text.Encoding.ASCII.GetBytes(m_strInitVector)
Dim saltValueBytes As Byte()
saltValueBytes = System.Text.Encoding.ASCII.GetBytes(p_strSaltValue)
' Convert our plaintext into a byte array.
' Let us assume that plaintext contains UTF8-encoded characters.
Dim plainTextBytes As Byte()
plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText)
' First, we must create a password, from which the key will be derived.
' This password will be generated from the specified passphrase and
' salt value. The password will be created using the specified hash
' algorithm. Password creation can be done in several iterations.
Dim password As Rfc2898DeriveBytes
password = New Rfc2898DeriveBytes(m_strPassPhrase, _
saltValueBytes, _
m_strPasswordIterations)
' Use the password to generate pseudo-random bytes for the encryption
' key. Specify the size of the key in bytes (instead of bits).
Dim keyBytes As Byte()
Dim intKeySize As Integer = 0
intKeySize = CType((m_intKeySize / 8), Integer)
keyBytes = password.GetBytes(intKeySize)
' Create uninitialized Rijndael encryption object.
Dim symmetricKey As System.Security.Cryptography.RijndaelManaged
symmetricKey = New System.Security.Cryptography.RijndaelManaged
' It is reasonable to set encryption mode to Cipher Block Chaining
' (CBC). Use default options for other symmetric key parameters.
symmetricKey.Mode = System.Security.Cryptography.CipherMode.CBC
'symmetricKey.Padding = PaddingMode.Zeros
' Generate encryptor from the existing key bytes and initialization
' vector. Key size will be defined based on the number of the key
' bytes.
Dim encryptor As System.Security.Cryptography.ICryptoTransform
encryptor = symmetricKey.CreateEncryptor(keyBytes, initVectorBytes)
' Define memory stream which will be used to hold encrypted data.
Dim memoryStream As System.IO.MemoryStream
memoryStream = New System.IO.MemoryStream
' Define cryptographic stream (always use Write mode for encryption).
Dim cryptoStream As System.Security.Cryptography.CryptoStream
cryptoStream = New System.Security.Cryptography.CryptoStream(memoryStream, _
encryptor, _
System.Security.Cryptography.CryptoStreamMode.Write)
' Start encrypting.
cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length)
' Finish encrypting.
cryptoStream.FlushFinalBlock()
' Convert our encrypted data from a memory stream into a byte array.
Dim cipherTextBytes As Byte()
cipherTextBytes = memoryStream.ToArray()
' Close both streams.
memoryStream.Close()
cryptoStream.Close()
' Convert encrypted data into a base64-encoded string.
Dim cipherText As String
cipherText = Convert.ToBase64String(cipherTextBytes)
' Return encrypted string.
strReturn = cipherText
Catch ex As Exception
strReturn = Nothing
End Try
Return strReturn
End Function
Here are couple of example outputs:
RealBlue : mLvmg4ntx2mSewxoYrwBPA==
B4A : ZOKsIfBqR05Kr1KAzZsDuA==
c@nb3@goo6p@ssw0rd : BzEPjMg87c28cPlf5WePfhYVKHBNB0lU6jGJ0o+3V0Y=
In THIS thread there is another one is already converted.
Can anyone help me converting this one also.
Thanks in advance.