Hash seems incorrect in RC2

T

tshad

I have a function I am using to encrypt Keys and it doesn't seem to use the
Hash I asked for.

************************************

Public Shared Function TripleDESEncode(ByVal value As String, ByVal key
As String) As String

Dim des As New Security.Cryptography.TripleDESCryptoServiceProvider

des.IV = New Byte(7) {}

Dim pdb As New Security.Cryptography.PasswordDeriveBytes(key, New
Byte(-1) {})

des.Key = pdb.CryptDeriveKey("RC2", "MD5", 128, New Byte(7) {})

Dim ms As New IO.MemoryStream((value.Length * 2) - 1)

Dim encStream As New Security.Cryptography.CryptoStream(ms,
des.CreateEncryptor(), Security.Cryptography.CryptoStreamMode.Write)

Dim plainBytes As Byte() = Text.Encoding.UTF8.GetBytes(value)

encStream.Write(plainBytes, 0, plainBytes.Length)

encStream.FlushFinalBlock()

Dim encryptedBytes(CInt(ms.Length - 1)) As Byte

ms.Position = 0

ms.Read(encryptedBytes, 0, CInt(ms.Length))

encStream.Close()

Return Convert.ToBase64String(encryptedBytes)

End Function
***********************************

In the above code, I am using this:

des.Key = pdb.CryptDeriveKey("RC2", "MD5", 128, New Byte(7) {})

But if I look at pdp.hashname, I get "SHA1"?????

Why is that?

Doesn't it use what I pass?

Thanks,

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top