没有在java解密代码生成的输出未知错误

时间:2014-04-22 08:05:19

标签: java performance web-services java-ee encryption

我没有从此代码中获取任何输出我通过加密文本进行解密,但输出未知,我无法找到代码有什么问题请帮助代码发布在下面

private void findMeaning(HttpServletResponse resp,String encryptText) throws NoSuchAlgorithmException, 
    InvalidKeySpecException, 
    NoSuchPaddingException, 
    InvalidKeyException,
    InvalidAlgorithmParameterException, 
    UnsupportedEncodingException, 
    IllegalBlockSizeException, 
    BadPaddingException, 
    IOException, ShortBufferException, NoSuchProviderException{ 
       String text = encryptText;
        String secretKey="ezeon8547";

       KeySpec keySpec = new PBEKeySpec(secretKey.toCharArray(), salt, iterationCount);
       SecretKey key = SecretKeyFactory.getInstance("PBEWithMD5AndDES").generateSecret(keySpec);        
        // Prepare the parameter to the ciphers
       AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, iterationCount);
       //Decryption process; same key will be used for decr
       dcipher=Cipher.getInstance(key.getAlgorithm());
       dcipher.init(Cipher.DECRYPT_MODE, key,paramSpec);
       byte[] enc = new sun.misc.BASE64Decoder().decodeBuffer(text);//possible problem here please resolve

       byte[] utf8 = dcipher.doFinal(enc);
       String charSet="UTF-8";     
       String plainStr = new String(utf8, charSet);

          sendResponse(resp, "Pincode city:" +plainStr);


    }}

我检查并发现当我停止运行此代码byte[] enc = new sun.misc.BASE64Decoder().decodeBuffer(text);然后响应发送正确,但当此代码参与程序时程序停止提供输出请帮助这行代码我相信问题是上面的代码

0 个答案:

没有答案