3DES confusion

Discussion in 'ASP .Net' started by tshad, Jan 3, 2007.

  1. tshad

    tshad Guest

    I am trying to use 3DES to encrypt my keys and am using VS 2003.

    I am confused with some code I have that seems to use a hash (MD5) in the
    3DES. But a Hash is one way. You are not suppose to be able to decrypt it.
    The only thing I can figure is that it is using the hash only on the key.

    Also, the

    *****************************************************
    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("TripleDES", "MD5", 168, 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
    *************************************************************

    The other thing I noticed was that when I looked at the value pdb.HashName
    and des.pdb.HashName it shows "SHA1" instead of "MD5"????

    Am I doing something wrong here?

    Thanks,

    Tom
     
    tshad, Jan 3, 2007
    #1
    1. Advertising

  2. tshad

    Mark Rae Guest

    "tshad" <> wrote in message
    news:...

    >I am trying to use 3DES to encrypt my keys and am using VS 2003.
    >
    > I am confused with some code I have that seems to use a hash (MD5) in the
    > 3DES. But a Hash is one way. You are not suppose to be able to decrypt
    > it. The only thing I can figure is that it is using the hash only on the
    > key.


    Contact me privately and I'll give you a copy of my 3DES encryption base
    class - it's in C#, but should give you enough guidance to solve your
    problem...
     
    Mark Rae, Jan 3, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. wolf
    Replies:
    0
    Views:
    855
  2. Amitesh Hati

    3DES Encryption

    Amitesh Hati, May 29, 2006, in forum: Java
    Replies:
    1
    Views:
    4,893
    Jan Peter Stotz
    May 31, 2006
  3. tshad

    8 byte key for 3DES

    tshad, Jan 4, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    439
    Mark Rae
    Jan 4, 2007
  4. Ning

    pycrypto 3DES keysize

    Ning, Dec 13, 2006, in forum: Python
    Replies:
    2
    Views:
    446
  5. Tim Mackey

    3des encryption question

    Tim Mackey, Dec 19, 2003, in forum: ASP .Net Security
    Replies:
    1
    Views:
    122
    Cowboy \(Gregory A. Beamer\)
    Dec 19, 2003
Loading...

Share This Page