-
Cryptographyc
Hi there.
I am using the following function to Encrypt data and I need to use the Key (vnKey) and IV (vnIV) with the values they have in the function, but the function is not using those values, it is using a ramdom generated values "I guess". So how can tell the fuction to use the values I have specified?
Thanks a lot.
Private Function EncryptString(ByVal Value As String) As String
Dim mCSP As SymmetricAlgorithm
Dim ct As ICryptoTransform
Dim ms As MemoryStream
Dim cs As CryptoStream
Dim byt() As Byte
Dim vnKey(7) As Byte
Dim vnIV(7) As Byte
vnKey(0) = 77
vnKey(1) = 30
vnKey(2) = 159
vnKey(3) = 161
vnKey(4) = 67
vnKey(5) = 52
vnKey(6) = 130
vnKey(7) = 160
vnIV(0) = 227
vnIV(1) = 8
vnIV(2) = 214
vnIV(3) = 0
vnIV(4) = 255
vnIV(5) = 221
vnIV(6) = 164
vnIV(7) = 163
mCSP = New DESCryptoServiceProvider()
ct = mCSP.CreateEncryptor(vnKey, vnIV)
byt = Encoding.UTF8.GetBytes(Value)
ms = New MemoryStream()
cs = New CryptoStream(ms, ct, CryptoStreamMode.Write)
cs.Write(byt, 0, byt.Length)
cs.FlushFinalBlock()
cs.Close()
Return Convert.ToBase64String(ms.ToArray())
End Function
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks