File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes 8- byte array Intialization Vector Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "8- byte array Intialization Vector" Watch "8- byte array Intialization Vector" New topic
Author

8- byte array Intialization Vector

Salman Moha
Greenhorn

Joined: Jul 19, 2005
Posts: 12
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

Joined: Oct 27, 2005
Posts: 19783
    
  20

Have you tried the same in Java?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Salman Moha
Greenhorn

Joined: Jul 19, 2005
Posts: 12
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

Joined: Jun 24, 2003
Posts: 3274
    
    5

I'd have thought your first example would work just fine, is it not?


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: 8- byte array Intialization Vector