wood burning stoves 2.0*
The moose likes Security and the fly likes Decryption DESede doesn't work completely good ??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Security
Bookmark "Decryption DESede doesn Watch "Decryption DESede doesn New topic

Decryption DESede doesn't work completely good ???

Jochen Maes

Joined: Dec 03, 2002
Posts: 20
hi all,
i'm encrypting and decrypting a file in the same program. But the Decrypted file doesn't appear well some parts are (seemingly still encrypted)
here is the code i use:
System: JDK1.3.1
JCE 1.2.2
Thank you
* test.java
* Created on 4 december 2002, 14:19
package com.dastt.sejo.denc;
import java.io.*;
import java.util.*;
import javax.crypto.*;
import javax.crypto.spec.*;
import java.security.*;
import java.security.spec.*;
* @author U97488
public class test {

/** Creates a new instance of test */
public test() {

* @param args the command line arguments
public static void main(String[] args) {
Security.addProvider(new com.sun.crypto.provider.SunJCE());
File in = new File("c:/tmp/test.txt");
File out = new File("c:/tmp/test_encrypted.txt");
Key key=null;
byte b[] = new byte[1024];
try {
String enckey="012345678901234567890123456789012345678901234";
byte[] rawkey = enckey.getBytes();

DESedeKeySpec keyspec = new DESedeKeySpec(rawkey);
SecretKeyFactory keyfactory = SecretKeyFactory.getInstance("DESede");
key = keyfactory.generateSecret(keyspec);

Cipher ci = Cipher.getInstance("DESede/CBC/NoPadding");
byte[] initValue = new byte[8];
IvParameterSpec ivSpec = new IvParameterSpec(initValue);
AlgorithmParameters algParams = AlgorithmParameters.getInstance("DESede");
ci.init(ci.ENCRYPT_MODE, key);
CipherInputStream cis = new CipherInputStream((InputStream)new FileInputStream(in), ci);
InputStreamReader isr = new InputStreamReader(cis, "ISO-8859-1");
StringBuffer strbfr = new StringBuffer();
char c[] = new char[1024];
ci.init(ci.DECRYPT_MODE, key, algParams);
CipherOutputStream cos = new CipherOutputStream((OutputStream)new FileOutputStream("c:/tmp/testJoc.txt"), ci);
OutputStreamWriter osr = new OutputStreamWriter(cos, "ISO-8859-1");

} catch (Exception e) {

}catch(Exception e){

Jochen Maes

Joined: Dec 03, 2002
Posts: 20
problem solved:

should be
I agree. Here's the link: http://aspose.com/file-tools
subject: Decryption DESede doesn't work completely good ???
Similar Threads
How/Where to store encryption key?
Triple Des Pin Encryption
Overhead IO : The cryptic case of the extra bytes
encrypt data
encrypt data in database