Javax.crypto.IllegalBlockSizeException :Urgent please help !!!!
error message:
===================================================
javax.crypto.IllegalBlockSizeException: Input length (with padding) not multiple of 8 bytes
at com.ibm.crypto.provider.DESCipher.a(Unknown Source)
at com.ibm.crypto.provider.DESCipher.engineDoFinal(Unknown Source)
at com.ibm.crypto.provider.DESCipher.engineDoFinal(Unknown Source)
at javax.crypto.Cipher.doFinal(Unknown Source)
at CreateRandomImage.doGet(CreateRandomImage.java:69)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.servlet.engine.webapp.StrictServletInstance.doService(ServletManager.java:827)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet._service (StrictLifecycleServlet.java:167)
at com.ibm.servlet.engine.webapp.IdleServletState.service(StrictLifecycleServlet.java:297)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet.service(StrictLifecycleServlet.java:110)
at com.ibm.servlet.engine.webapp.ServletInstance.service(ServletManager.java:472)
at com.ibm.servlet.engine.webapp.ValidServletReferenceState.dispatch(ServletManager.java:1012)
at com.ibm.servlet.engine.webapp.ServletInstanceReference.dispatch(ServletManager.java:913)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:721)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:374)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:118)
at com.ibm.servlet.engine.srt.WebAppInvoker.doForward(WebAppInvoker.java:134)
at com.ibm.servlet.engine.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:239)
at com.ibm.servlet.engine.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:67)
at com.ibm.servlet.engine.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:151)
at com.ibm.servlet.engine.oselistener.OSEListenerDispatcher.service(OSEListener.java:315)
at com.ibm.servlet.engine.http11.HttpConnection.handleRequest(HttpConnection.java:60)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:332)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:251)
at com.ibm.ws.util.CachedThread.run(ThreadPool.java:138)
============================================================
code part:
++++++++++++++++++++++++++++++++++++++++++++++++++++++
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
String strValue = "";
// fixedness encrypt key
byte[] ENCRYPT_KEY = { 2, 69, -70, -5, -94, -15, -22, 93 };
// get encrypted data from request
String encryptedData = request.getParameter("encrypt");
byte[] encryptedDataByte = encryptedData.getBytes();
byte[] enbytes = encryptedData.getBytes();
System.out.println("encrypted data >>>>>>>>" + encryptedData);
try
SecureRandom sr = new SecureRandom();
DESKeySpec dks = new DESKeySpec(ENCRYPT_KEY);
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
javax.crypto.SecretKey keyEncrypt = keyFactory.generateSecret(dks);
Cipher cipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, keyEncrypt, sr);
System.out.println(" ========== length " + encryptedData.getBytes().length);
// when execute the sentence, Exception throw !!!
byte decryptedData[] = cipher.doFinal(enbytes);
// dencrypted data
strValue = new String(decryptedData);
}catch(Exception ex){
ex.printStackTrace();
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
// get encrypted data from request
String encryptedData = request.getParameter("encrypt");
byte[] encryptedDataByte = encryptedData.getBytes();
byte[] enbytes = encryptedData.getBytes();Right here. This gets "encrypt" as a String, and tries to get the ciphertext as that String's bytes. You can't do that. String does horrible, horrible things to ciphertext.
If you're going to transmit ciphertext as strings, you need to use Base64 to encode it before transfer, and then decode it after, to get your ciphertext back.
Grant
Similar Messages
-
Javax.crypto.IllegalBlockSizeException help?
I am making a plain text encrypt/decrypt program for personal use.
It will compile just fine, but if I try to run the decryption part, it freaks out on me.
It keeps on saying:
javax.crypto.IllegalBlockSizeException: Input length must be multiple of 16 when decrypting with padded cipher
This is my code. I cannot figure out what is wrong...
import java.io.*;
import java.util.*;
import java.security.*;
import javax.crypto.*;
import javax.crypto.spec.SecretKeySpec;
import javax.crypto.spec.IvParameterSpec;
import static methods.methods.*;
public class Base
public static void main()
Scanner kbReader = new Scanner(System.in);
clear("Method > ");
String s = kbReader.next();
if(s.equals("output"))
try{output();}
catch(Exception e){e.printStackTrace();}
if(s.equals("input"))
try{input();}
catch(Exception e){e.printStackTrace();}
if(s.equals("genKey"))
genKey();
if(s.equals("x"))
clear("Well it stopped.");
else
main();
public static void output()
throws IOException,
NoSuchAlgorithmException,
NoSuchPaddingException,
InvalidKeyException,
IllegalBlockSizeException,
BadPaddingException,
InvalidAlgorithmParameterException
Scanner kbReader = new Scanner(System.in);
Scanner kbr = new Scanner(System.in);
clear("What is the name of the file?\nName > ");
fileName = kbReader.next();
String s2 = "/Users/ewsmith/base/" + fileName;
FileWriter fw = new FileWriter(s2, true);
PrintWriter output = new PrintWriter(fw, true);
clear("Key > ");
byte key[] = new byte[16];
for(int j=0; j<16; j++)
key[j] = kbReader.nextByte();
clear("IV > ");
byte ivBytes[] = new byte[16];
for(int j=0; j<16; j++)
ivBytes[j] = kbReader.nextByte();
IvParameterSpec iv = new IvParameterSpec(ivBytes);
String s = new String("");
String ss = new String("");
clear("Enter what you want output to a file.\nType 'x' to finish writing.\n\n");
while(true)
s = kbReader.nextLine();
if(s.equalsIgnoreCase("x"))
break;
ss = ss + s + "\n";
byte data[] = ss.getBytes("UTF-8");
Cipher c = Cipher.getInstance("AES/CBC/PKCS5PADDING");
SecretKeySpec k = new SecretKeySpec(key, "AES");
c.init(Cipher.ENCRYPT_MODE, k, iv);
c.doFinal(data);
for(int j=0; j<data.length; j++)
output.print(data[j] + " ");
clear("This is your key.\n\n");
for(int j=0; j<key.length; j++)
System.out.print(key[j] + " ");
println("\n\nType in 'x' and press enter to continue.");
boolean alive = true;
while(alive)
String s3 = kbr.nextLine();
if(s3.equalsIgnoreCase("x"))
alive = false;
byte[] IV = c.getIV();
clear("This is your IV:\n\n");
for(int j=0; j<IV.length; j++)
print(IV[j] + " ");
println("\n\nType x to continue.\n");
String ew = "";
while(true)
ew = kbReader.nextLine();
if(ew.equalsIgnoreCase("x"))
break;
output.close();
fw.close();
public static void input()
throws IOException,
NoSuchAlgorithmException,
NoSuchPaddingException,
InvalidKeyException,
IllegalBlockSizeException,
BadPaddingException,
InvalidAlgorithmParameterException
Scanner kbReader = new Scanner(System.in);
Scanner kbr = new Scanner(System.in);
Cipher c = Cipher.getInstance("AES/CBC/PKCS5PADDING");
clear("What is the name of the file?\nName > ");
fileName = kbr.next();
String s2 = "/Users/ewsmith/base/" + fileName;
Scanner sf = new Scanner(new File(s2));
int num = 1;
clear("Key > ");
byte key[] = new byte[16];
for(int j=0; j<16; j++)
key[j] = kbReader.nextByte();
clear("IV > ");
byte ivBytes[] = new byte[16];
for(int j=0; j<16; j++)
ivBytes[j] = kbReader.nextByte();
IvParameterSpec iv = new IvParameterSpec(ivBytes);
SecretKeySpec k = new SecretKeySpec(key, "AES");
c.init(Cipher.DECRYPT_MODE, k, iv);
clear("This text was stored inside the file.\n\n\n");
int j = 0;
ArrayList<Byte> ip = new ArrayList<Byte>();
while(sf.hasNext())
ip.add(sf.nextByte());
byte input[] = new byte[ip.size()];
for(j=0; j<ip.size(); j++)
input[j] = ip.get(j);
String recovered = new String(c.doFinal(input));
println(recovered);
sf.close();
ip.clear();
input = null;
println("\n\nType in 'x' and press enter to continue.");
boolean alive = true;
while(alive)
String s = kbReader.nextLine();
if(s.equalsIgnoreCase("x"))
alive = false;
public static void genKey()
Scanner kbReader = new Scanner(System.in);
clear();
Random ranGen = new SecureRandom();
byte[] aesKey = new byte[16];
ranGen.nextBytes(aesKey);
for(int j=0; j<aesKey.length; j++)
System.out.print(aesKey[j] + " ");
println("\n\nType in 'x' and press enter to continue.");
boolean alive = true;
while(alive)
String s = kbReader.nextLine();
if(s.equalsIgnoreCase("x"))
alive = false;
public static String fileName = "";
}Thank you in advance for answering.
EDIT:
It now says:
+ at com.sun.crypto.provider.SunJCE_h.b(DashoA12275)+
+ at com.sun.crypto.provider.SunJCE_h.b(DashoA12275)+
+ at com.sun.crypto.provider.AESCipher.engineDoFinal(DashoA12275)+
+ at javax.crypto.Cipher.doFinal(DashoA12275)+
+ at Base.input(Base.java:184)+
+ at Base.main(Base.java:23)+
+ at __SHELL3.run(__SHELL3.java:6)+
+ at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)+
+ at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)+
+ at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)+
+ at java.lang.reflect.Method.invoke(Method.java:585)+
+ at bluej.runtime.ExecServer$3.run(ExecServer.java:819)+
Could this be an IV error?
Can negative IV's be used?
Edited by: eric_smith on Jan 6, 2010 9:25 PM
Edited by: eric_smith on Jan 7, 2010 9:51 AMI turned this:
String recovered = new String(c.doFinal(input));into this:
String recovered = new String(input);and used 0's for the key and iv and the text was 'decrypted'.
Something tells me the problem is in the output and input cipher.init()
Can someone enlighten me as to what I am doing wrong?
EDIT: btw, the code came from the input method.
Edited by: eric_smith on Jan 7, 2010 9:28 PM -
Very urgent : please help !!!! Blowfish problem
Greetings people,
I have devised an application which reads the value from file and encrypts it (using Blowfish)......The file is then read and decrypted accordingly..............
Problem : I seem to be able to encrypt and further decrypt file(s) which size is below 100 bytes. Anything beyond that will trigger the following :
javax.crypto.IllegalBlockSizeException: Input length (with padding) not multiple of 8 bytes
at com.sun.crypto.provider.SunJCE_h.a(DashoA6275)
at com.sun.crypto.provider.SunJCE_h.b(DashoA6275)
at com.sun.crypto.provider.SunJCE_h.b(DashoA6275)
at com.sun.crypto.provider.BlowfishCipher.engineDoFinal(DashoA6275)
at javax.crypto.Cipher.doFinal(DashoA6275)
at LockDownBase.decrypt(LockDownBase.java:144)
Could someone please help me with this dilemma as time is of the essence at this point and I really need to get this thing up and running. (ps. It is necessary for me to retain the usage of the Base64 Encoder as I am conducting a study on the usage of this Encoder).
Thank you for the help
<code>
import java.io.*;
import java.math.*;
import java.security.*;
import javax.crypto.*;
import javax.crypto.spec.*;
import sun.misc.*;
public class LockDownBase {
private static String keyFile = "c:\\encode\\blowfishbase.txt";
public static String new_key (String me) throws Exception {
//Get a blowfish key
KeyGenerator keyGenerator = KeyGenerator.getInstance("Blowfish");
keyGenerator.init(128);
SecretKey key = keyGenerator.generateKey();
System.out.println("OK");
byte [] encoded = key.getEncoded();
FileOutputStream fos = new FileOutputStream(keyFile);
fos.write(encoded);
fos.close();
return me;
//initKey
public static Key initKey() throws Exception{
FileInputStream in = new FileInputStream(keyFile);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int i;
while((i=in.read()) != -1){
baos.write(i);
in.close();
byte [] keys = baos.toByteArray();
SecretKeySpec key = new SecretKeySpec(keys,"Blowfish");
Key keyword = key;
return key;
public static String encrypt (String location) throws Exception{
//PrintStream is deprecated, but works fine in jdk1.1.7b
//PrintStream output1 = new PrintStream(outFile1);
//get_key
String testme = "dummy";
Key key = initKey();
Cipher cipher = Cipher.getInstance("Blowfish/ECB/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, key);
// read in the input file
String line;
StringBuffer buffer = new StringBuffer();
FileInputStream fis = new FileInputStream(location);
InputStreamReader isr = new InputStreamReader(fis);
Reader in = new BufferedReader(isr);
int ch;
while ((ch = in.read()) > -1) {
buffer.append((char)ch);
in.close();
line = buffer.toString();
byte [] cipherText = cipher.doFinal(line.getBytes("UTF8"));
//output1.print(" ");
// output1.println("ciphertext.length = " + cipherText.length);
// print out representation of ciphertext to general output file
BASE64Encoder encoding = new BASE64Encoder();
String feed = encoding.encode(cipherText);
FileOutputStream outFile2 = new FileOutputStream(location);
PrintStream output2 = new PrintStream(outFile2);
output2.close();
String dir = location;
FileOutputStream outFile3 = new FileOutputStream(dir);
PrintStream output3 = new PrintStream(outFile3);
output3.println(feed);
output3.close();
return location;
public static String decrypt (String location) throws Exception{
Key key = initKey();
String line;
String dir = location;
FileReader far = new FileReader (dir);
BufferedReader stdin = new BufferedReader(far,8192);
String line = null;
while ((line = stdin.readLine()) != null){
BASE64Decoder decoding = new BASE64Decoder();
byte[] decrypted = decoding.decodeBuffer(line);
Cipher cipher = Cipher.getInstance("Blowfish/ECB/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, key);
byte [] decryptedtext = cipher.doFinal(decrypted);
String output = new String (decryptedtext,"UTF8");
System.out.println(output);
FileOutputStream outFile1 = new FileOutputStream(location);
PrintStream output1 = new PrintStream(outFile1);
output1.println(output);
output1.close();
return location;
</code>The error message says it all.
Input length (with padding) not multiple of 8 bytes
As you are using PKCS5Padding you will have an output data whose length is padded with 1 a 8 bytes. For instance, if your original data have 1023 bytes, it is padded with 1 byte - total length = 1024. It your original data have 1024 bytes, it will be padded with 8 bytes (not 0 as you could think).
You have some problem encoding and decoding Base-64 - it is not yielding the original encrypted results. Your best friend is System.out.println of the length of the original and encrypted data. -
Javax.crypto.IllegalBlockSizeException: Input length must be multiple of 8
Hello!
I have encrypted/decrypted one String with DES. I tried to do so on one computer and it seams to work fine. But what I realy want is to encrypt 3 String: username, id, and password, and send them to server. On server I want to decrypt them, and use them to check in database if the person exist. I save this 3 String in an ArrayList, and use ObjectInput/OutputStream to send and receive. Here is some of my code(I hope it is enough for you to help me solve this problem,othervice I will send more).
I get this error: javax.crypto.IllegalBlockSizeException: Input length must be multiple of 8 when decrypting with padded cipher
public class CryptDecryptString {
public byte[] cryptString( String password) throws UnsupportedEncodingException, InvalidKeyException, NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException{
byte [] plainTextPassword = password.getBytes("UTF-8");
System.out.println(new String(plainTextPassword,"UTF-8"));
//SecureRandom sr = new SecureRandom();
String nyckeln = "HELLOHEJ";
byte rawKeyData[] = nyckeln.getBytes();
DESKeySpec dks = new DESKeySpec(rawKeyData);
SecretKey key = SecretKeyFactory.getInstance("DES").generateSecret(dks);
Cipher cipher=Cipher.getInstance("DES");
cipher.init(Cipher.ENCRYPT_MODE, key);//, sr);
System.out.println("\nStart encryption:");
cipher.init(Cipher.ENCRYPT_MODE,key);
byte[] cipherTextPassword=cipher.doFinal(plainTextPassword);
System.out.println("Finish encryption:");
System.out.println(new String(cipherTextPassword));
return cipherTextPassword;
}// end cryptString
public byte[]decryptString(byte[] cipherTextPassword) throws InvalidKeyException, NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, UnsupportedEncodingException {
String nyckeln = "HELLOHEJ";
byte rawKeyData[] = nyckeln.getBytes();
DESKeySpec dks = new DESKeySpec(rawKeyData);
SecretKey key = SecretKeyFactory.getInstance("DES").generateSecret(dks);
Cipher cipher=Cipher.getInstance("DES");
System.out.println("\nStart decryption:");
cipher.init(Cipher.DECRYPT_MODE,key);
byte[] plainTextPassword=cipher.doFinal(cipherTextPassword);
System.out.println(" Finnish decryption:");
System.out.println(new String(plainTextPassword,"UTF-8"));
return plainTextPassword;
}// end decryptString
{public boolean TryLogin(String uname, String insID, String pass) throws Exception{
connect();
//sendOutStream = new DataOutputStream(socket.getOutputStream());
sendOutStream = new ObjectOutputStream(socket.getOutputStream());
InputStream inpuStream;
inpuStream = socket.getInputStream();
BufferedReader in= new BufferedReader(new InputStreamReader(inpuStreamtext s));
CryptDecryptString cryptString = new CryptDecryptString();
String krypteradeUname = cryptString.cryptString(uname);
String krypteradeInsID = cryptString.cryptString(insID);
String krypteradePass = cryptString.cryptString(pass);
ArrayList<String> loggInPersonInfo= new ArrayList<String>();
loggInPersonInfo.add(krypteradeUname);
loggInPersonInfo.add(krypteradeInsID);
loggInPersonInfo.add(krypteradePass);
Object[] elements = loggInPersonInfo.toArray();
for(int i=0; i < elements.length ; i++)
System.out.println(elements);
sendOutStream.writeObject(loggInPersonInfo);
sendOutStream.close();
sendOutStream.flush();
System.out.println("Skickade information...");
int line = in.read();
if(line > 0){
user_id = line;
return true;
}else{
return false;Here is the rest of code
public void CheckLogin() throws SQLException, IOException, InterruptedException, InvalidKeyException, NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, Exception{
/**InputStream inpuStream;
inpuStream = client.getInputStream();
BufferedInputStream in= new BufferedInputStream(inpuStream);//(new BufferedReader(inpuStream));
inpuStream = client.getInputStream();
ObjectInputStream objectIn = new ObjectInputStream(inpuStream);
ArrayList<String> personLoggIn = new ArrayList<String>();
String krypteradeUname;
String krypteradeInsID ;
String krypteradePass ;
personLoggIn = null;
personLoggIn = (ArrayList<String>)objectIn.readObject();
for (int i=0;i<personLoggIn.size();i++) {
krypteradeUname=personLoggIn.get(0);
krypteradeInsID =personLoggIn.get(1);
krypteradePass = personLoggIn.get(2);
System.out.println(i);
inpuStream.close();
CryptDecryptString decryptString = new CryptDecryptString();
byte[] byteUname = decryptString.decryptString((krypteradeUname.getBytes()));
String username = new String(byteUname);
byte[] byteInsID = decryptString.decryptString((krypteradeInsID.getBytes()));
String instanceID = new String(byteInsID);
byte[] bytePassword = decryptString.decryptString((krypteradePass.getBytes()));
String password = new String(bytePassword);
Please help!
Thanks! -
Urgent please help, this program should work
Urgent please help.
I need to solve or I will be in big trouble.
This program works at my home computer which is not networked.
The hard disk was put onto another computer at another location whihc is networked. Here my program worked on Monday 14 october but since for the last two days it is not working without me changing any code. Why do I receive this error message???
Error: 500
Location: /myJSPs/jsp/portal-project2/processviewfiles_dir.jsp
Internal Servlet Error:
javax.servlet.ServletException
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:460)
at jsp.portal_0002dproject2.processviewfiles_dir_1._jspService(processviewfiles_dir_1.java:162)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
at org.apache.tomcat.core.Handler.service(Handler.java:235)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:536)
Root cause:
java.lang.NullPointerException
at jsp.portal_0002dproject2.processviewfiles_dir_1._jspService(processviewfiles_dir_1.java:132)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
at org.apache.tomcat.core.Handler.service(Handler.java:235)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:536)foolishmatt,
The code is quit large.
to understand the program I think all the code needs to be examined.
I would need to send to you in an email.
Here is my e-mail
[email protected]
if you contact me than I can send the code to you.
Thank you in advance. -
hi friends
iam writing and reading an encryted text to a file . this code executes well on windows xp o.s but does not executes on Macintosh ,solaris and linux systems.
when executed it throws javax.crypto.IllegalBlockSizeException and javax.crypto.BadPaddingException .
pls i am damp urgent need of it so kindly resolve my problem
Below is the code.
Thanks in advance.
--------------------------------------------------code----------------------------------------
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.Cipher;
import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
public class EncryptionExample
static SecretKey key = null;
static String text="A=1,B=2,C=3";
static String xform = "Blowfish/CFB/PKCS5Padding";
private static byte[] iv =
{ 0x0a, 0x01, 0x02, 0x03, 0x04, 0x0b, 0x0c, 0x0d };
public EncryptionExample() throws Exception
key=EncryptionExample.getGeneratedKey();
public static void writeToFile() throws Exception
FileWriter file = null;
BufferedWriter fileOutput = null;
byte[] dataBytes = null;
byte[] encBytes = null;
try {
file = new FileWriter("C:\\Test.txt");
fileOutput= new BufferedWriter(file);
dataBytes = text.getBytes("UTF8");
encBytes = encrypt(dataBytes, key, xform);
String encStr = Base64.encode(encBytes);
fileOutput.write(encStr);
fileOutput.close();
} catch (Exception e) {
e.printStackTrace();
// reading encryted text from file
public static void readFromFile() throws Exception
FileReader filerdr = null;
BufferedReader fileInput = null;
byte[] decBytes = null;
String decrystr = null;
String enText = null;
try {
filerdr = new FileReader("C:\\Test.txt");
fileInput = new BufferedReader(filerdr);
while ((enText = fileInput.readLine())!=null)
byte[] decrypted = Base64.decode(enText);
decBytes = decrypt(decrypted, key, xform);
decrystr=new String(decBytes,"UTF8");
System.out.println("decrypted string token , "+decrystr);
fileInput.close();
}catch (Exception e) {
e.printStackTrace();
private static byte[] encrypt(byte[] inpBytes,SecretKey key, String xform) throws Exception {
Cipher cipher = Cipher.getInstance(xform);
IvParameterSpec dps = new IvParameterSpec(iv);
cipher.init(Cipher.ENCRYPT_MODE, key,dps);
return cipher.doFinal(inpBytes);
private static byte[] decrypt(byte[] inpBytes,SecretKey key, String xform) throws Exception
Cipher cipher = Cipher.getInstance(xform);
IvParameterSpec dps = new IvParameterSpec(iv);
cipher.init(Cipher.DECRYPT_MODE, key,dps);
return cipher.doFinal(inpBytes);
private static SecretKey getGeneratedKey() throws Exception
// Generate a secret key
KeyGenerator kg = KeyGenerator.getInstance("Blowfish");
kg.init(128); // 56 is the keysize. Fixed for DES
SecretKey key = kg.generateKey();
return key ;
public static void main(String[] unused) throws Exception {
new EncryptionExample();
EncryptionExample.writeToFile();
EncryptionExample.readFromFile();
}You are very lucky to get this working at all, even on Windows! You encrypt the whole of your string at one go and write it to a file using
fileOutput= new BufferedWriter(file);
dataBytes = text.getBytes("UTF8");
encBytes = encrypt(dataBytes, key, xform);
String encStr = Base64.encode(encBytes);
fileOutput.write(encStr);
fileOutput.close();but you then try to decrypt it a line at a time using
while ((enText = fileInput.readLine())!=null)
byte[] decrypted = Base64.decode(enText);
decBytes = decrypt(decrypted, key, xform);
decrystr=new String(decBytes,"UTF8");
System.out.println("decrypted string token , "+decrystr);
fileInput.close();This just does not make sense. If you encrypt all at one time you must decrypt all at one time.
Your code happens to work because the Base64 encoding puts everything on one line. The fact that this seems to work does not make it correct.
P.S. Your code works on my Linux FC5 so I have no idea why you get the exceptions! -
Javax.crypto.IllegalBlockSizeException: 6 trailing bytes
Hi everybody!
I'm facing a error when i try to encrypt a string with symmetric algorithm DES. I try to run the following code on Redhat:
byte[] data="It is a test!".getBytes();
Cipher cipher = Cipher.getInstance(algName);
cipher.init(Cipher.ENCRYPT_MODE, key);
int blocksize=cipher.getBlockSize();
System.out.println("--------blocksize: "+blocksize); // blocksize=8
byte[] cipherByte = cipher.doFinal(data); // 52 line
The error showing is:
javax.crypto.IllegalBlockSizeException: 6 trailing bytes
at gnu.javax.crypto.jce.cipher.CipherAdapter.engineDoFinal(CipherAdapter.java:491)
at javax.crypto.Cipher.doFinal(Cipher.java:495)
at javax.crypto.Cipher.doFinal(Cipher.java:461)
at cn.com.webinfo.security.SymmetricAlgorithm.encrypt(SymmetricAlgorithm.java:52)
at cn.com.webinfo.stest.MainSymmetricAlgorithm.main(MainSymmetricAlgorithm.java:32)
Can any one support.
Thanks and waiting your replies.It would help if you showed the content of the String referenced by 'algName' since it looks to me like you are using "DES/ECB/NoPadding" and not either "DES" or "DES/ECB/PKCS5Padding".
-
Kernel panics, message saying "You need to restart your computer.Hold down the Power..." I am in the middle of HSC very URGENT please help!! Mac keeps needing to restart!!
I looked in console and its saying that it may be because of Sophos Anti-Virus, i deleted and uninstalled all traces of Sophos but looked in console and this is some of the lines coming up:
26/09/13 10:11:17.945 PM com.apple.launchd: (com.sophos.intercheck[6460]) posix_spawn("/Library/Sophos Anti-Virus/InterCheck.app/Contents/MacOS/InterCheck", ...): No such file or directory
26/09/13 10:11:17.945 PM com.apple.launchd: (com.sophos.autoupdate[6461]) posix_spawn("/Library/Sophos Anti-Virus/SophosAutoUpdate.app/Contents/MacOS/SophosAutoUpdate", ...): No such file or directory
26/09/13 10:11:17.945 PM com.apple.launchd: (com.sophos.notification[6462]) posix_spawn("/Library/Sophos Anti-Virus/SophosAntiVirus.app/Contents/MacOS/SophosAntiVirus", ...): No such file or directory
26/09/13 10:11:17.946 PM com.apple.launchd: (com.sophos.intercheck[6460]) Exited with code: 1
26/09/13 10:11:17.946 PM com.apple.launchd: (com.sophos.intercheck) Throttling respawn: Will start in 10 seconds
26/09/13 10:11:17.946 PM com.apple.launchd: (com.sophos.autoupdate[6461]) Exited with code: 1
26/09/13 10:11:17.946 PM com.apple.launchd: (com.sophos.autoupdate) Throttling respawn: Will start in 10 seconds
26/09/13 10:11:17.946 PM com.apple.launchd: (com.sophos.notification[6462]) Exited with code: 1
26/09/13 10:11:17.946 PM com.apple.launchd: (com.sophos.notification) Throttling respawn: Will start in 10 seconds
26/09/13 10:11:18.291 PM Safari: self <TabContentView: 0x7f8d5dd1aa50>
26/09/13 10:11:22.617 PM Safari: self <TabContentView: 0x7f8d5db7bb00>
26/09/13 10:11:27.866 PM Safari: self <TabContentView: 0x7f8d5c331a70>
26/09/13 10:12:19.939 PM com.apple.launchd.peruser.501: (com.sophos.uiserver[6487]) posix_spawn("/Library/Sophos Anti-Virus/SophosUIServer.app/Contents/MacOS/SophosUIServer", ...): No such file or directory
26/09/13 10:12:19.939 PM com.apple.launchd.peruser.501: (com.sophos.uiserver[6487]) Exited with code: 1
26/09/13 10:12:19.939 PM com.apple.launchd.peruser.501: (com.sophos.uiserver) Throttling respawn: Will start in 10 seconds"
Looked all over computer and cant find anything of Sophos please help very urgent!That was all that there was in the most recent one, how long do you think it could take to fix?
Here is the second most recent:
Wed Sep 25 15:39:39 2013
panic(cpu 0 caller 0xffffff80002c4794): Kernel trap at 0xffffff7f81757965, type 14=page fault, registers:
CR0: 0x0000000080010033, CR2: 0xffffff81acc397fe, CR3: 0x000000001e2b5025, CR4: 0x00000000000606e0
RAX: 0x000000001d31a000, RBX: 0x0000000000000000, RCX: 0x0000000000000000, RDX: 0x0000000000000000
RSP: 0xffffff80b0dbb710, RBP: 0xffffff80b0dbb820, RSI: 0x0000000000000000, RDI: 0x0000000000000001
R8: 0x000000000000000a, R9: 0x0000000000000378, R10: 0x0000000000000128, R11: 0x0000000000000378
R12: 0xffffff800c626400, R13: 0x0000000000000000, R14: 0x0000000000000000, R15: 0xffffff81acc39802
RFL: 0x0000000000010246, RIP: 0xffffff7f81757965, CS: 0x0000000000000008, SS: 0x0000000000000010
CR2: 0xffffff81acc397fe, Error code: 0x0000000000000000, Faulting CPU: 0x0
Backtrace (CPU 0), Frame : Return Address
0xffffff80b0dbb3c0 : 0xffffff8000220792
0xffffff80b0dbb440 : 0xffffff80002c4794
0xffffff80b0dbb5f0 : 0xffffff80002da55d
0xffffff80b0dbb610 : 0xffffff7f81757965
0xffffff80b0dbb820 : 0xffffff7f817667a0
0xffffff80b0dbb840 : 0xffffff7f8173a58e
0xffffff80b0dbb870 : 0xffffff7f8177fb6f
0xffffff80b0dbb8a0 : 0xffffff7f81779632
0xffffff80b0dbb8d0 : 0xffffff7f8177d7d5
0xffffff80b0dbb900 : 0xffffff7f8177c6db
0xffffff80b0dbb9e0 : 0xffffff7f817412b8
0xffffff80b0dbba10 : 0xffffff7f81778684
0xffffff80b0dbba30 : 0xffffff7f817449ce
0xffffff80b0dbbb60 : 0xffffff7f81741a4c
0xffffff80b0dbbbc0 : 0xffffff8000655f3e
0xffffff80b0dbbbe0 : 0xffffff800065681a
0xffffff80b0dbbc40 : 0xffffff8000656fbb
0xffffff80b0dbbd80 : 0xffffff80002a3f08
0xffffff80b0dbbe80 : 0xffffff8000223096
0xffffff80b0dbbeb0 : 0xffffff80002148a9
0xffffff80b0dbbf10 : 0xffffff800021bbd8
0xffffff80b0dbbf70 : 0xffffff80002aef10
0xffffff80b0dbbfb0 : 0xffffff80002daec3
Kernel Extensions in backtrace:
com.apple.driver.AppleIntelHD3000Graphics(7.3.2)[A2328231-E577-32FF-B20F-D08BDC FE9C51]@0xffffff7f81738000->0xffffff7f8179bfff
dependency: com.apple.iokit.IOPCIFamily(2.7)[5C23D598-58B2-3204-BC03-BC3C0F00BD32]@0xffffff 7f80889000
dependency: com.apple.iokit.IONDRVSupport(2.3.4)[7C8672C4-8B0D-3CCF-A79A-23C62E90F895]@0xff ffff7f80d2e000
dependency: com.apple.iokit.IOGraphicsFamily(2.3.4)[D0A1F6BD-E66E-3DD8-9913-A3AB8746F422]@0 xffffff7f80cf5000
BSD process name corresponding to current thread: WindowServer
Mac OS version:
11G63b
Kernel version:
Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64
Kernel UUID: FF3BB088-60A4-349C-92EA-CA649C698CE5
System model name: MacBookPro8,1 (Mac-94245B3640C91C81)
System uptime in nanoseconds: 1866666823698
last loaded kext at 480357661446: com.apple.filesystems.smbfs 1.7.2 (addr 0xffffff7f80795000, size 241664)
last unloaded kext at 303348424187: com.apple.driver.AppleUSBUHCI 5.1.0 (addr 0xffffff7f80af7000, size 65536)
loaded kexts:
com.sophos.kext.sav 8.0.14
org.virtualbox.kext.VBoxNetAdp 4.2.16
org.virtualbox.kext.VBoxNetFlt 4.2.16
org.virtualbox.kext.VBoxUSB 4.2.16
org.virtualbox.kext.VBoxDrv 4.2.16
com.logmein.driver.LogMeInSoundDriver 1.0.2
com.Greatdy.driver.SystemAudioCapture 1.0.0
com.apple.filesystems.smbfs 1.7.2
com.apple.driver.AppleHWSensor 1.9.5d0
com.apple.driver.AppleMikeyHIDDriver 122
com.apple.iokit.IOBluetoothSerialManager 4.0.8f17
com.apple.driver.AudioAUUC 1.59
com.apple.driver.AppleHDA 2.2.5a5
com.apple.driver.AppleMikeyDriver 2.2.5a5
com.apple.driver.AGPM 100.12.75
com.apple.driver.AppleUpstreamUserClient 3.5.9
com.apple.driver.SMCMotionSensor 3.0.2d6
com.apple.driver.AppleSMCPDRC 5.0.0d8
com.apple.iokit.IOUserEthernet 1.0.0d1
com.apple.Dont_Steal_Mac_OS_X 7.0.0
com.apple.driver.AudioIPCDriver 1.2.3
com.apple.driver.AppleSMCLMU 2.0.1d2
com.apple.driver.ApplePolicyControl 3.1.33
com.apple.driver.ACPI_SMC_PlatformPlugin 5.0.0d8
com.apple.driver.AppleIntelHD3000Graphics 7.3.2
com.apple.driver.AppleBacklight 170.2.2
com.apple.driver.AppleLPC 1.6.0
com.apple.driver.AppleMCCSControl 1.0.33
com.apple.filesystems.autofs 3.0
com.apple.driver.AppleUSBTCButtons 227.6
com.apple.driver.BroadcomUSBBluetoothHCIController 4.0.8f17
com.apple.driver.AppleUSBTCKeyboard 227.6
com.apple.driver.AppleIRController 312
com.apple.AppleFSCompression.AppleFSCompressionTypeDataless 1.0.0d1
com.apple.AppleFSCompression.AppleFSCompressionTypeZlib 1.0.0d1
com.apple.BootCache 33
com.apple.iokit.SCSITaskUserClient 3.2.1
com.apple.driver.XsanFilter 404
com.apple.iokit.IOAHCISerialATAPI 2.0.3
com.apple.iokit.IOAHCIBlockStorage 2.1.0
com.apple.driver.AppleUSBHub 5.1.0
com.apple.driver.AppleFWOHCI 4.9.0
com.apple.driver.AirPort.Brcm4331 561.7.22
com.apple.driver.AppleSDXC 1.2.2
com.apple.iokit.AppleBCM5701Ethernet 3.2.4b8
com.apple.driver.AppleEFINVRAM 1.6.1
com.apple.driver.AppleSmartBatteryManager 161.0.0
com.apple.driver.AppleAHCIPort 2.3.1
com.apple.driver.AppleUSBEHCI 5.1.0
com.apple.driver.AppleACPIButtons 1.5
com.apple.driver.AppleRTC 1.5
com.apple.driver.AppleHPET 1.7
com.apple.driver.AppleSMBIOS 1.9
com.apple.driver.AppleACPIEC 1.5
com.apple.driver.AppleAPIC 1.6
com.apple.driver.AppleIntelCPUPowerManagementClient 195.0.0
com.apple.nke.applicationfirewall 3.2.30
com.apple.security.quarantine 1.4
com.apple.security.TMSafetyNet 8
com.apple.driver.AppleIntelCPUPowerManagement 195.0.0
com.apple.iokit.IOSerialFamily 10.0.5
com.apple.driver.DspFuncLib 2.2.5a5
com.apple.iokit.IOSurface 80.0.2
com.apple.iokit.IOFireWireIP 2.2.5
com.apple.driver.AppleHDAController 2.2.5a5
com.apple.iokit.IOHDAFamily 2.2.5a5
com.apple.iokit.IOAudioFamily 1.8.6fc18
com.apple.kext.OSvKernDSPLib 1.3
com.apple.driver.AppleGraphicsControl 3.1.33
com.apple.driver.AppleSMC 3.1.3d10
com.apple.driver.IOPlatformPluginLegacy 5.0.0d8
com.apple.driver.AppleSMBusPCI 1.0.10d0
com.apple.driver.AppleBacklightExpert 1.0.4
com.apple.driver.IOPlatformPluginFamily 5.1.1d6
com.apple.iokit.IONDRVSupport 2.3.4
com.apple.driver.AppleSMBusController 1.0.10d0
com.apple.driver.AppleIntelSNBGraphicsFB 7.3.2
com.apple.iokit.IOGraphicsFamily 2.3.4
com.apple.kext.triggers 1.0
com.apple.driver.AppleUSBBluetoothHCIController 4.0.8f17
com.apple.iokit.IOBluetoothFamily 4.0.8f17
com.apple.driver.AppleThunderboltDPInAdapter 1.8.5
com.apple.driver.AppleThunderboltDPAdapterFamily 1.8.5
com.apple.driver.AppleThunderboltPCIDownAdapter 1.2.5
com.apple.driver.AppleUSBMultitouch 230.5
com.apple.iokit.IOUSBHIDDriver 5.0.0
com.apple.driver.AppleUSBMergeNub 5.1.0
com.apple.driver.AppleUSBComposite 5.0.0
com.apple.iokit.IOSCSIMultimediaCommandsDevice 3.2.1
com.apple.iokit.IOBDStorageFamily 1.7
com.apple.iokit.IODVDStorageFamily 1.7.1
com.apple.iokit.IOCDStorageFamily 1.7.1
com.apple.iokit.IOSCSIArchitectureModelFamily 3.2.1
com.apple.driver.AppleThunderboltNHI 1.6.0
com.apple.iokit.IOThunderboltFamily 2.0.3
com.apple.iokit.IOUSBUserClient 5.0.0
com.apple.iokit.IOFireWireFamily 4.4.8
com.apple.iokit.IO80211Family 420.3
com.apple.iokit.IOEthernetAVBController 1.0.1b1
com.apple.iokit.IONetworkingFamily 2.1
com.apple.iokit.IOAHCIFamily 2.0.8
com.apple.iokit.IOUSBFamily 5.1.0
com.apple.driver.AppleEFIRuntime 1.6.1
com.apple.iokit.IOHIDFamily 1.7.1
com.apple.iokit.IOSMBusFamily 1.1
com.apple.security.sandbox 177.11
com.apple.kext.AppleMatch 1.0.0d1
com.apple.driver.DiskImages 331.7
com.apple.iokit.IOStorageFamily 1.7.2
com.apple.driver.AppleKeyStore 28.18
com.apple.driver.AppleACPIPlatform 1.5
com.apple.iokit.IOPCIFamily 2.7
com.apple.iokit.IOACPIFamily 1.4 -
Urgent, Please help me in this problem.I am getting problem while installation
I am using Windows 8 in my system. I am trying to install Sql Server in system . Everything is fine, but finally when i click on install button i am getting the following error .
please help me quickly. I well be thankful to you.Triple post meanwhile:
http://social.msdn.microsoft.com/Forums/en-US/7fafa499-ca1e-42f7-a117-73df924d9847/urgent-please-help-me-in-this-problemi-am-getting-problem-while-installation?forum=sqlsetupandupgrade
http://social.msdn.microsoft.com/Forums/en-US/a1c7978c-2f84-495f-a8b6-9e9fe46654d7/getting-problem-while-installing-sql-server-2012?forum=sqlsetupandupgrade
Olaf Helper
[ Blog] [ Xing] [ MVP] -
Encrypting and Decrypting Data(Its Very Urgent, Please Help.)
Hi,
Can anyone tell me some idea in the below mentioned details.
Iam creating a Function for Encrypting and Decrypting Data Values using
DBMS_OBFUSCATION_TOOLKIT with UTL_RAW.CAST_TO_RAW by using
Key Value as normal.
But the problem, is it possible to have the key value more than 8.
Its showing me error when i give the key value less than 8 or more than 8.
Can u tell me why it happens, is that the limit of the key value or is any other way to do that.
Its Very Urgent, Please Help.
Thanks,
Murali.VIs this what you're looking for?
Usage Notes
If the input data or key given to the DES3DECRYPT procedure is empty, then the procedure raises the error ORA-28231 "Invalid input to Obfuscation toolkit."
If the input data given to the DES3DECRYPT procedure is not a multiple of 8 bytes, the procedure raises the error ORA-28232 "Invalid input size for Obfuscation toolkit." ORA-28233 is NOT applicable for the DES3DECRYPT function.
If the key length is missing or is less than 8 bytes, then the procedure raises the error ORA-28234 "Key length too short." Note that if larger keys are used, extra bytes are ignored. So a 9-byte key will not generate an exception.
C. -
Date format Problem in OAF R12 Urgent Please help!!!
We have acustom application in OAF which was developed in 11i. Now we migrated the same to R12.
In this there are two date fileds getting dispayed on the page and the query for the same is
SELECT TO_CHAR (SYSDATE, 'dd-mm-yyyy') AS CURRENT_DATE, UPPER (TO_CHAR (SYSDATE - 10, 'mon-yy')) AS g_period, UPPER (TO_CHAR (SYSDATE + 5, 'mon-yy')) AS gnext_period, TO_CHAR (sysdate,'dd-mon-yyyy') as today_date, TO_CHAR (sysdate - 1,'dd-mon-yyyy') as yesterday_date FROM DUAL
In 11i version the output is dispaying correctly but in R12 the current date is dispayed as
Start Date 04-Nov-5242
End Date 04-Nov-5241
As per logic it should be
Start Date 09-Feb-2012
End Date 10-Feb-2012
Please help..Urgent issue.Here are the answers to your problems :
1. Once u restart , the oracle services and the database is not mounting automatically.That is because, when you install the Oracle Oracle8i Standard Edition Release (8.1.7), the two key services namely
OracleOraHome81TNSListner and
OracleService<your SID name>
are configured as manual start ( check the NT --> start>setting>control panel>services. )
For the database to start automatically the next time you start your machine, these two services will have to be put into "Automatic Start" mode.
< for this double click on the respective service, select the "Automatic" radio button and click on ok>.
Now when you restart the machine, your database will be automatically mounted.
2. this as explained above is a corollory to the above problem. you can start or stop your database on NT using the "Services" window....
hope this helps.
bye.
Hi All,
I have installed Oracle Oracle8i Standard Edition Release (8.1.7) from technet site.
I have installed it on windows NT 4.0 .
Installation is fine.
I can access or get into SQL prompt .
I have created a database also.
1st problem
My problem is once I restart the Machine and try to access SQL plus .it gives me an error
ORA-01034: Oracle not available
ORA-27101: shared memory realm does not exist.
2nd problem
I dont know how to start and stop the database , as there is nothing to do that in the start menu of Oracle .
How do i do this .
This is very urgent please help.
regards,
Preeti -
hi guys urgent please help me ASAP my ipod touch 4g reboots/restarts over and over again and i cant enter DFU mode cause my home button is stuck/broken please help guys i cant enter itunes too cause it said it needs my passcode the problem is i cant even enter my passcode in my ipod touch cause its rebooting over and over again help please guys
- See if this program will place it in recovery mode since that erases the iPod and bypasses the passocode.
RecBoot: Easy Way to Put iPhone into Recovery Mode
- Next try letting the battery fully drain. The try again. -
Set Page "HEIGHT" ---Very Urgent, Please Help me on this issue. Please.
Hi all ,
Very Urgent, Please Help me on this issue.
when_now_form trigger i set set maximize the window and MDI. And my window and canvas is same height (1500). The formsweb.cfg also changed to 1500. But still I can not view full page on web. Where to I change the properties. Please help.
SelvamIs your form running inside the browser window (with SeparateFrame=False)? If the browser is maximized, and your form is maximized, yet you cannot see the entire screen, you can run with SeparateFrame=True. You can do that on the browser line.
-
Javax.crypto.IllegalBlockSizeException: Input data length not a multiple
Hi All ,
M worknig with NWCE 7.1.1. I have written code for decryption for decryption. Earlier my web dynpro application was on CE7.1. We migrated it to CE 7.1.1 just week ago after migrating to CE 7.1.1 , on execution of decryption code m gtting as
javax.crypto.IllegalBlockSizeException: Input data length not a multiple of blocksize
i have written following code for decryption.
public String decrypt( String encryptedString, String encryptionKey )
String UNICODE_FORMAT = "UTF8";
try
if ( encryptedString == null || encryptedString.trim().length() <= 0 )
throw new IllegalArgumentException( "encrypted string was null or empty" );
byte[] keyAsBytes = encryptionKey.getBytes(UNICODE_FORMAT);
keySpec = new DESKeySpec(keyAsBytes);
keyFactory = SecretKeyFactory.getInstance( "DES" );
cipher = Cipher.getInstance( "DES" );
SecretKey key = keyFactory.generateSecret( keySpec );
cipher.init( Cipher.DECRYPT_MODE, key );
BASE64Decoder base64decoder = new BASE64Decoder();
byte[] cleartext = base64decoder.decodeBuffer( encryptedString );
byte[] ciphertext = cipher.doFinal( cleartext );
return new String( ciphertext );
}catch (Exception e){
IWDMessageManager messageManager = wdComponentAPI.getMessageManager();
messageManager.reportException("Error while Decryption");
e.printStackTrace();
return "";
This code was working fine in CE 7.1 . After migrating to CE 7.1.1 it started giving this error.Thank you for your answer
how the code is usedI have hardcoded key, example
byte[] key = "123456789abcdefg".getBytes();and String for crypt (Example, String in = "green";)
Then I encrypt string in with code above (in qwestion body) and get exception IllegalBlockSizeException: Input data length not a multiple of blocksize
String encrypt(String in) throws Exception{
String out="";
byte[] key = "123456789abcdefg".getBytes();
Cipher ecipher = Cipher.getInstance("AES");
ecipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "AES"));
byte[] utf8 = in.getBytes("UTF8");
byte[] enc = ecipher.doFinal(utf8);
out = (new sun.misc.BASE64Encoder().encode(enc)).toString();
return out;
}Clients use JRE1.4 or high. I have JRE1.4 and all work correctly. Also, many clients have 1.4, but only part of they get exception. Code is in the server (this is part of servlet)
This function run in one thread and doesn't use shared resources -
R2_AQ_JMS MDB deployment Error--Urgent, please help!!
Deploy a simple MDB to Oracle9iASR2, follow the steps:
1. Define the MDB in ejb-jar.xml
<message-driven>
<description>MDB Queue Listener</description>
<display-name>QueueListener Message Driven Bean</display-name>
<ejb-name>QueueListenerMDB</ejb-name>
<ejb-class>mdb.QueueListenerMDB</ejb-class>
<transaction-type>Container</transaction-type>
<message-driven-destination>
<jms-destination-type>javax.jms.Topic</jms-destination-type>
</message-driven-destination>
</message-driven>
2. Modify the orion-ejb-jar.xml
<message-driven-deployment
name="QueueListenerMDB"
destination-location="jms/SalesTopic"
connection-factory-location="jms/theTopicConnectionFactory"
subscription-name="MDBSUB"
>
</message-driven-deployment>
3. define the resource-provider in application.xml
<resource-provider class="oracle.jms.OjmsContext" name="SalesJMS">
<description> OJMS/AQ </description>
<property name="url" value="jdbc:oracle:thin:@dell2400:1521:mydb"></property>
<property name="username" value="user"></property>
<property name="password" value="pssword"></property>
</resource-provider>
4. Deploy the ear file and got the following error:
java.lang.NullPointerException
at com.evermind.server.ejb.MessageDrivenHome.<init>(MessageDrivenHome.java:280)
at com.evermind.server.ejb.EJBPackageDeployment.bindHomes(EJBPackageDeployment.java:239
at com.evermind.server.ejb.EJBContainer.postInit(EJBContainer.java:589)
at com.evermind.server.Application.postInit(Application.java:420)
at com.evermind.server.administration.ServerApplicationInstallation.finish(ServerApplic
ationInstallation.java:491)
at java.lang.reflect.Method.invoke(Native Method)
at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:80)
at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:64)
Any idea on what's the cause of this. It seems that the Oracle 9i's support of MDB differs significantly from R1. The demo sample that works for R1 no longer work for R2. For example, the following DD doesn't seem to work with R2.
<resource-ref>
<res-ref-name>jms/Queue/senderQueueConnectionFactory</res-ref-name>
<res-type>javax.jms.QueueConnectionFactory</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<resource-env-ref>
<resource-env-ref-name>jms/Queue/senderQueue</resource-env-ref-name>
<resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
</resource-env-ref>
<resource-ref>
<res-ref-name>jms/Topic/senderTopicConnectionFactory</res-ref-name>
<res-type>javax.jms.TopicConnectionFactory</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
Please help!! This is very urgent! Thanks in advance!<jms-destination_type> tag should be <destination-type> its a oracle error
Maybe you are looking for
-
How can I merge my contacts on iphone but keep the text msgs
I use my phone a lot for work and a lot of my correspondance is through text msgs. My best friend and I share the apple account and we have the same contacts so when I add it to the account my phone she does the same and we come up with duplicate con
-
J4680 goes offline then ready every few seconds tying up system resources
Please, I hope someone can help with this. I have been back and forth with tech support for SIX MONTHS and can get no satisfaction (and I try). My J4680 wireless printer keeps turning itself offline for a few seconds, then goes back to ready a few se
-
Goods Movement 351 not posting to PCA
For our new plant implentation, we create STO (ME23N), GI - 351 movement type, and GR - 101. No sales order, No delivery. Also 101 GR doesnt create financial document. at good issue 351 movement type : inv FG 13300100 Cr inv FG 13300100 Dr F
-
Continuous video playback from a video playlist
I have a smart playlist that filters down to all video podcasts that have never been played. I can't seem to get it to play multiple video podcasts continuously. Shuffle is off. Any help is appreciated.
-
Hi A few hours ago I cleaned my Macbook Pro with Clean My Mac 2. I just cleared all the cache and language files and such. Now when I rebooted my Mac, I went into Windows 8.1 with BootCamp. So for so good. When I rebooted again, I wanted to go in OS