Package org.bouncycastle.crypto

Examples of org.bouncycastle.crypto.CryptoException


                    SecretKeyFactory factory = SecretKeyFactory.getInstance(PBE_ALGORITHM, PROVIDER);
                    SecretKey tmp = factory.generateSecret(pbeKeySpec);
                    SecretKey secret = new SecretKeySpec(tmp.getEncoded(), SECRET_KEY_ALGORITHM);
                    return secret;
            } catch (Exception e) {
                    throw new CryptoException(e.getMessage());
            }
    }
View Full Code Here


                    byte[] salt = new byte[SALT_LENGTH];
                    random.nextBytes(salt);
                    String saltHex = bytesToHex(salt);
                    return saltHex;
            } catch (Exception e) {
              throw new CryptoException(e.getMessage());
            }
    }
View Full Code Here

                  String encryptedHex = bytesToHex(encryptedText);
 
                  return ivHex + encryptedHex;
 
          } catch (Exception e) {
                  throw new CryptoException("Unable to encrypt");
          }
    }
View Full Code Here

                    decryptionCipher.init(Cipher.DECRYPT_MODE, secret, ivspec);
                    byte[] decryptedText = decryptionCipher.doFinal(hexToBytes(encryptedHex));
                    String decrypted = new String(decryptedText, "UTF-8");
                    return decrypted;
            } catch (Exception e) {
                    throw new CryptoException("Unable to decrypt");
            }
    }
View Full Code Here

TOP

Related Classes of org.bouncycastle.crypto.CryptoException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.