The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
September 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Urgent !! I encounter IllegaBlockSizeException error

Posted by Jeffrey on September 18, 2001 at 3:57 AM

i don't have problem when i compile this program but when i run this program after i compiled it is encountered this error "error: my.com.epedas.iSecurityException: IllegalBlockSizeException in decrypt: javax.crypto.IllegaBlockSizeException: Input length not multiple of 8 bytes"

this is the source code
import my.com.epedas.base.*;
import my.com.epedas.security.*;
import my.com.epedas.system.*;

import java.util.*;
import java.io.*;
import java.sql.*;

public class NETLINK_RUNONCE
{

public static void main(String[] args)
{
String lic = "0005|acme.com|20010901|20200101";
try
{
int opt = Integer.parseInt(args[0]);

iKrypto krypto = new iKrypto("my.com.epedas",10);
switch(opt)
{

case 1:
{
DataOutputStream file = new DataOutputStream(new FileOutputStream("license.properties"));


System.out.println("writing license");
System.out.println("lic: "+lic);
lic = krypto.encrypt(lic);
file.writeBytes(lic);

System.out.println("lic: "+lic);
System.out.println("len: "+lic.length());
file.close();
}
break;

case 2:
{
DataInputStream file = new DataInputStream(new FileInputStream("license.properties"));

System.out.println("reading license");
int c = -1;
// boolean marked = false;
StringBuffer buff = new StringBuffer();


while ((c = file.read()) != -1)
buff.append((byte)c);




/* if (!marked) {
file.mark(8);
marked = true;
} else {
marked = false;
}
lic = buff.toString();
*/

System.out.println("lic: "+lic);
System.out.println("len: "+lic.length());
String read=new String(krypto.decrypt(lic));
System.out.println("read: "+read);
file.close();
}

break;

default:
System.out.println("choose 1/2");
}

}
catch(Exception e)
{
System.out.println("error : "+e);
}

}
}



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us