EDN Admin
Well-known member
Hello !
i have this code to encrypt a string:
<span style="color:#0000ff; font-size:small
<pre class="prettyprint lang-vb Private Function Encrypt(ByVal strText As String) As String
Dim strEncrKey As String ="A3&8_="
Dim byKey() As Byte = {}
Dim IV() As Byte = {&H12, &H34, &H56, &H78, &H90, &HAB, &HCD, &HEF}
byKey = System.Text.Encoding.UTF8.GetBytes(strEncrKey.Substring(0, 8))
Dim des As New DESCryptoServiceProvider()
Dim inputByteArray() As Byte = Encoding.UTF8.GetBytes(strText)
Dim ms As New MemoryStream()
Dim cs As New CryptoStream(ms, des.CreateEncryptor(byKey, IV), CryptoStreamMode.Write)
cs.Write(inputByteArray, 0, inputByteArray.Length)
cs.FlushFinalBlock()
Return Convert.ToBase64String(ms.ToArray())
End Function[/code]
But the problem is that with the same strEncrKey , with the same input string string everytime that i run the function the output is different.
What should i change to get the same result when the key and the string are not changed ?
Thank you !
<span style="color:#0000ff; font-size:small <br/>
<span style="font-size:small <span style="font-size:small
View the full article
i have this code to encrypt a string:
<span style="color:#0000ff; font-size:small
<pre class="prettyprint lang-vb Private Function Encrypt(ByVal strText As String) As String
Dim strEncrKey As String ="A3&8_="
Dim byKey() As Byte = {}
Dim IV() As Byte = {&H12, &H34, &H56, &H78, &H90, &HAB, &HCD, &HEF}
byKey = System.Text.Encoding.UTF8.GetBytes(strEncrKey.Substring(0, 8))
Dim des As New DESCryptoServiceProvider()
Dim inputByteArray() As Byte = Encoding.UTF8.GetBytes(strText)
Dim ms As New MemoryStream()
Dim cs As New CryptoStream(ms, des.CreateEncryptor(byKey, IV), CryptoStreamMode.Write)
cs.Write(inputByteArray, 0, inputByteArray.Length)
cs.FlushFinalBlock()
Return Convert.ToBase64String(ms.ToArray())
End Function[/code]
But the problem is that with the same strEncrKey , with the same input string string everytime that i run the function the output is different.
What should i change to get the same result when the key and the string are not changed ?
Thank you !
<span style="color:#0000ff; font-size:small <br/>
<span style="font-size:small <span style="font-size:small
View the full article