本文整理了Java中javax.crypto.BadPaddingException.printStackTrace()
方法的一些代码示例,展示了BadPaddingException.printStackTrace()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BadPaddingException.printStackTrace()
方法的具体详情如下:
包路径:javax.crypto.BadPaddingException
类名称:BadPaddingException
方法名:printStackTrace
暂无
代码示例来源:origin: shuzheng/zheng
e.printStackTrace();
代码示例来源:origin: shuzheng/zheng
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
代码示例来源:origin: aa112901/remusic
private static byte[] decrypt(byte[] content, String password) {
try {
byte[] keyStr = getKey(password);
SecretKeySpec key = new SecretKeySpec(keyStr, "AES");
Cipher cipher = Cipher.getInstance(algorithmStr);//algorithmStr
cipher.init(Cipher.DECRYPT_MODE, key);// ʼ
byte[] result = cipher.doFinal(content);
return result; //
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (NoSuchPaddingException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
}
return null;
}
代码示例来源:origin: aa112901/remusic
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
代码示例来源:origin: Pay-Group/best-pay-sdk
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
代码示例来源:origin: aa112901/remusic
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
代码示例来源:origin: aa112901/remusic
private static byte[] encrypt(byte[] content, byte[] keyBytes) {
byte[] encryptedText = null;
if (!isInited) {
init();
}
/**
*类 SecretKeySpec
*可以使用此类来根据一个字节数组构造一个 SecretKey,
*而无须通过一个(基于 provider 的)SecretKeyFactory。
*此类仅对能表示为一个字节数组并且没有任何与之相关联的钥参数的原始密钥有用
*构造方法根据给定的字节数组构造一个密钥。
*此构造方法不检查给定的字节数组是否指定了一个算法的密钥。
*/
Key key = new SecretKeySpec(keyBytes, "AES");
try {
// 用密钥初始化此 cipher。
cipher.init(Cipher.ENCRYPT_MODE, key);
} catch (InvalidKeyException e) {
e.printStackTrace();
}
try {
//按单部分操作加密或解密数据,或者结束一个多部分操作。(不知道神马意思)
encryptedText = cipher.doFinal(content);
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
}
return encryptedText;
}
代码示例来源:origin: 0opslab/opslabJutil
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
代码示例来源:origin: 0opslab/opslabJutil
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
代码示例来源:origin: schwabe/ics-openvpn
@Override
public byte[] getSignedData(String alias, byte[] data) throws RemoteException {
try {
return SimpleSigner.signData(data);
} catch (IOException e) {
e.printStackTrace();
} catch (NoSuchPaddingException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
} catch (InvalidKeySpecException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
}
// Something failed, return null
return null;
}
代码示例来源:origin: cn.leancloud.android/avoscloud-sdk
private byte[] decrypt(String cmp, SecretKey sk, IvParameterSpec IV, byte[] ciphertext) {
try {
Cipher c = Cipher.getInstance(cmp);
c.init(Cipher.DECRYPT_MODE, sk, IV);
return c.doFinal(ciphertext);
} catch (NoSuchAlgorithmException nsae) {
Log.e("AESdemo", "no cipher getinstance support for " + cmp);
} catch (NoSuchPaddingException nspe) {
Log.e("AESdemo", "no cipher getinstance support for padding " + cmp);
} catch (InvalidKeyException e) {
Log.e("AESdemo", "invalid key exception");
} catch (InvalidAlgorithmParameterException e) {
Log.e("AESdemo", "invalid algorithm parameter exception");
} catch (IllegalBlockSizeException e) {
Log.e("AESdemo", "illegal block size exception");
} catch (BadPaddingException e) {
Log.e("AESdemo", "bad padding exception");
e.printStackTrace();
}
return null;
}
代码示例来源:origin: com.alibaba.dauth/sdk-client
public synchronized String encrypt(String data) {
if (opmode != ENCRYPT_MODE) {
return null;
}
if (data == null) {
return null;
}
byte[] encData = null;
try {
encData = cipher.doFinal(data.getBytes(UTF8));
} catch (IllegalBlockSizeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (BadPaddingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (encData == null) {
return null;
}
return new String(Base64.encodeBase64(encData), UTF8);
}
代码示例来源:origin: com.alibaba.dauth/sdk-client
public synchronized String encrypt(String data) {
if (opmode != ENCRYPT_MODE) {
return null;
}
if (data == null) {
return null;
}
byte[] encData = null;
try {
encData = cipher.doFinal(data.getBytes(UTF8));
} catch (IllegalBlockSizeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (BadPaddingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (encData == null) {
return null;
}
return new String(Base64.encodeBase64(encData), UTF8);
}
代码示例来源:origin: wyh-spring-ecosystem-student/spring-boot-student
public static byte[] decrypt(byte[] content, String password) {
try {
KeyGenerator kgen = KeyGenerator.getInstance("AES");
kgen.init(128, new SecureRandom(password.getBytes()));
SecretKey secretKey = kgen.generateKey();
byte[] enCodeFormat = secretKey.getEncoded();
SecretKeySpec key = new SecretKeySpec(enCodeFormat, "AES");
Cipher cipher = Cipher.getInstance("AES");// 创建密码器
cipher.init(Cipher.DECRYPT_MODE, key);// 初始化
byte[] result = cipher.doFinal(content);
return result; // 加密
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (NoSuchPaddingException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
}
return null;
}
代码示例来源:origin: huangweicai/OkLibDemo
public static byte[] kkencrypt(Key keySpec, byte[] src) {
Cipher cip = null;
// SecretKey key=new SceretKey();
byte[] res = null;
try {
cip = Cipher.getInstance(CIPHER_ALGORITHM);
cip.init(Cipher.ENCRYPT_MODE, keySpec);
res = cip.doFinal(src);
} catch (NoSuchPaddingException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
}
return res;
}
代码示例来源:origin: badoualy/kotlogram
public static byte[] RSA(byte[] src, BigInteger key, BigInteger exponent) {
try {
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
PublicKey publicKey = keyFactory.generatePublic(new RSAPublicKeySpec(key, exponent));
Cipher cipher = Cipher.getInstance("RSA/ECB/NoPadding");
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
return cipher.doFinal(src);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (NoSuchPaddingException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
} catch (InvalidKeySpecException e) {
e.printStackTrace();
}
return null;
}
代码示例来源:origin: huangweicai/OkLibDemo
public static byte[] kkdecrypt(Key keySpec, byte[] src){
Cipher cip = null;
// SecretKey key=new SceretKey();
byte[] res = null;
try {
cip = Cipher.getInstance(CIPHER_ALGORITHM);
cip.init(Cipher.DECRYPT_MODE, keySpec);
res = cip.doFinal(src);
} catch (NoSuchPaddingException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
}
return res;
}
代码示例来源:origin: mouxuefei/KotlinMvpExample
public static byte[] rsa(JSONObject json, String publicKey) {
String text = json.toString();
try {
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
RSAPublicKey publicKey1 = loadPublicKeyByStr(publicKey);
cipher.init(Cipher.ENCRYPT_MODE, publicKey1);
return cipher.doFinal(text.getBytes("UTF-8"));
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
} catch (NoSuchPaddingException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
代码示例来源:origin: playerone-id/EosCommander
public static byte[] aesEncrypt( byte[] key, byte[] data, byte[] iv ) {
byte[] encrypted = null;
try {
SecretKey secureKey = new SecretKeySpec(key, "AES");
Cipher c = Cipher.getInstance("AES/CBC/PKCS5Padding");
c.init(Cipher.ENCRYPT_MODE, secureKey, new IvParameterSpec(iv));
encrypted = c.doFinal(data);
} catch (NoSuchPaddingException e) {
e.printStackTrace();
} catch (InvalidAlgorithmParameterException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
}
return encrypted;
}
代码示例来源:origin: woder/TorchBot
/**
* Encrypt or decrypt byte[] data using the specified key
*/
private static byte[] cipherOperation(int par0, Key par1Key, byte[] par2ArrayOfByte){
try
{
return createTheCipherInstance(par0, par1Key.getAlgorithm(), par1Key).doFinal(par2ArrayOfByte);
}
catch (IllegalBlockSizeException var4)
{
var4.printStackTrace();
}
catch (BadPaddingException var5)
{
var5.printStackTrace();
}
System.err.println("Cipher data failed!");
return null;
}
内容来源于网络,如有侵权,请联系作者删除!