none
How to do TripleDES encryption implementation with three different keys? RRS feed

  • Question

  • Hi Experts,

    We have been given three different encryption keys(Key1, key2, key3) and we were asked to implement Triple DES algorithm.

    As per .net documentation, Triple DES class constructor only accepts one key where as client mentioned that they need to encrypt it with three keys. 

    How to acheive same?


    • Edited by SrinivasCh Friday, September 28, 2018 12:06 PM
    Friday, September 28, 2018 12:05 PM

All replies

  • I think that you should represent each 56-bit key as a 64-bit value, combine them into a 192-bit value, and pass the result, as a byte array, to the CreateEncryptor function.


    Saturday, September 29, 2018 6:49 AM
  • How to implement TripleDES with DES algorithm is on the Wiki.

    [quote]

    Therefore, Triple DES uses a "key bundle" that comprises three DES keys, K<sub>1</sub>, K<sub>2</sub> and K<sub>3</sub>, each of 56 bits (excluding parity bits). The encryption algorithm is:

    ciphertext = E<sub>K3</sub>(D<sub>K2</sub>(E<sub>K1</sub>(plaintext)))

    [/quote]

    Basically you just need to encrpyt the plaintext block 3 times with the keys provided.

    Here's the code for encrypting data with DES.

    Tuesday, October 2, 2018 1:36 AM
    Answerer