• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

8- byte array Intialization Vector

 
Salman Moha
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I'm working on Triple DES encryption with parameters in JAVA 5:

Key Size : 16 bytes
Key : This is an MD5 hash of the shared key (eg: MD5 hash of omCryptoExchange in this case)
CipherMode : CBC (Cipher Block Chaining)
Padding Mode : PKCS7

How do I create an 8- byte array initialization vector with the following values in it, { 240, 3, 45, 29, 0, 76, 173, 59 } in java.

Equivalent C++ code is

// The Initialization Vector for the DES encryption routine
private readonly byte[] IV = new byte[8] { 240, 3, 45, 29, 0, 76, 173, 59 };
 
Rob Spoor
Sheriff
Pie
Posts: 20611
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried the same in Java?
 
Salman Moha
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:Have you tried the same in Java?



I trying to implement this in java.

private readonly byte[] IV = new byte[8] { 240, 3, 45, 29, 0, 76, 173, 59 };



Here's is my JAVA Code but skeptical about it.

private static byte[] IV = new byte[] { (byte)240, (byte)3, (byte)45,(byte)29, (byte)0, (byte)76, (byte)173, (byte)59 };


Method:
IvParameterSpec zeroIv = new IvParameterSpec(IV, 0, 8)


Please direct me.
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd have thought your first example would work just fine, is it not?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic