List of usage examples for org.bouncycastle.jce.provider BouncyCastleProvider BouncyCastleProvider
public BouncyCastleProvider()
From source file:encryption.AESCrypt.java
License:Open Source License
public static byte[] decrypt(byte[] key_aes, byte[] encrypted) throws InvalidKeyException, IllegalBlockSizeException, BadPaddingException { SecretKey secret = new SecretKeySpec(key_aes, "AES"); Cipher cipher;/* www . ja v a 2s . co m*/ try { if (Core.PROVIDER.equals(Core.SPONGEY_CASTLE)) cipher = Cipher.getInstance("AES/CBC/PKCS7Padding", new org.spongycastle.jce.provider.BouncyCastleProvider()); else cipher = Cipher.getInstance("AES/CBC/PKCS7Padding", new BouncyCastleProvider()); cipher.init(Cipher.DECRYPT_MODE, secret, new IvParameterSpec(iv)); return cipher.doFinal(encrypted); } catch (NoSuchAlgorithmException | NoSuchPaddingException e) { e.printStackTrace(); } catch (InvalidAlgorithmParameterException e) { e.printStackTrace(); } return null; }
From source file:encryption.AESCrypt.java
License:Open Source License
public static byte[] encryptNoPadding(byte[] key_aes, byte[] clean) throws InvalidKeyException, BadPaddingException, IllegalBlockSizeException { SecretKey secret = new SecretKeySpec(key_aes, "AES"); Cipher cipher;/*from w w w. j a v a 2 s . c o m*/ try { if (Core.PROVIDER.equals(Core.SPONGEY_CASTLE)) cipher = Cipher.getInstance("AES/CBC/NoPadding", new org.spongycastle.jce.provider.BouncyCastleProvider()); else cipher = Cipher.getInstance("AES/CBC/NoPadding", new BouncyCastleProvider()); cipher.init(Cipher.ENCRYPT_MODE, secret, new IvParameterSpec(iv)); return cipher.doFinal(clean); } catch (NoSuchAlgorithmException | NoSuchPaddingException e) { e.printStackTrace(); } catch (InvalidAlgorithmParameterException e) { e.printStackTrace(); } return null; }
From source file:encryption.AESCrypt.java
License:Open Source License
public static byte[] decryptNoPadding(byte[] key_aes, byte[] encrypted) throws InvalidKeyException, IllegalBlockSizeException, BadPaddingException { SecretKey secret = new SecretKeySpec(key_aes, "AES"); Cipher cipher;/*from ww w . j av a2 s . co m*/ try { if (Core.PROVIDER.equals(Core.SPONGEY_CASTLE)) cipher = Cipher.getInstance("AES/CBC/NoPadding", new org.spongycastle.jce.provider.BouncyCastleProvider()); else cipher = Cipher.getInstance("AES/CBC/NoPadding", new BouncyCastleProvider()); cipher.init(Cipher.DECRYPT_MODE, secret, new IvParameterSpec(iv)); return cipher.doFinal(encrypted); } catch (NoSuchAlgorithmException | NoSuchPaddingException e) { e.printStackTrace(); } catch (InvalidAlgorithmParameterException e) { e.printStackTrace(); } return null; }
From source file:encryption.SerpentCrypt.java
License:Open Source License
public static byte[] encryptNoPadding(byte[] key_aes, byte[] clean) throws InvalidKeyException, BadPaddingException, IllegalBlockSizeException { SecretKey secret = new SecretKeySpec(key_aes, "Serpent"); Cipher cipher;/*from www.ja v a2s.c om*/ try { if (Core.PROVIDER.equals(Core.SPONGEY_CASTLE)) cipher = Cipher.getInstance("Serpent/CBC/NoPadding", new org.spongycastle.jce.provider.BouncyCastleProvider()); else cipher = Cipher.getInstance("Serpent/CBC/NoPadding", new BouncyCastleProvider()); cipher.init(Cipher.ENCRYPT_MODE, secret, new IvParameterSpec(iv)); return cipher.doFinal(clean); } catch (NoSuchAlgorithmException | NoSuchPaddingException e) { e.printStackTrace(); } catch (InvalidAlgorithmParameterException e) { e.printStackTrace(); } return null; }
From source file:encryption.SerpentCrypt.java
License:Open Source License
public static byte[] decryptNoPadding(byte[] key_aes, byte[] encrypted) throws InvalidKeyException, IllegalBlockSizeException, BadPaddingException { SecretKey secret = new SecretKeySpec(key_aes, "Serpent"); Cipher cipher;//from ww w . j a va 2s . com try { if (Core.PROVIDER.equals(Core.SPONGEY_CASTLE)) cipher = Cipher.getInstance("Serpent/CBC/NoPadding", new org.spongycastle.jce.provider.BouncyCastleProvider()); else cipher = Cipher.getInstance("Serpent/CBC/NoPadding", new BouncyCastleProvider()); cipher.init(Cipher.DECRYPT_MODE, secret, new IvParameterSpec(iv)); return cipher.doFinal(encrypted); } catch (NoSuchAlgorithmException | NoSuchPaddingException e) { e.printStackTrace(); } catch (InvalidAlgorithmParameterException e) { e.printStackTrace(); } return null; }
From source file:encryption.SerpentCrypt.java
License:Open Source License
public static byte[] encrypt(byte[] key_aes, byte[] clean) throws InvalidKeyException, BadPaddingException, IllegalBlockSizeException { SecretKey secret = new SecretKeySpec(key_aes, "Serpent"); Cipher cipher;/*from ww w . java2 s . c o m*/ try { if (Core.PROVIDER.equals(Core.SPONGEY_CASTLE)) cipher = Cipher.getInstance("Serpent/CBC/PKCS7Padding", new org.spongycastle.jce.provider.BouncyCastleProvider()); else cipher = Cipher.getInstance("Serpent/CBC/PKCS7Padding", new BouncyCastleProvider()); cipher.init(Cipher.ENCRYPT_MODE, secret, new IvParameterSpec(iv)); return cipher.doFinal(clean); } catch (NoSuchAlgorithmException | NoSuchPaddingException e) { e.printStackTrace(); } catch (InvalidAlgorithmParameterException e) { e.printStackTrace(); } return null; }
From source file:encryption.SerpentCrypt.java
License:Open Source License
public static byte[] decrypt(byte[] key_aes, byte[] encrypted) throws InvalidKeyException, IllegalBlockSizeException, BadPaddingException { SecretKey secret = new SecretKeySpec(key_aes, "Serpent"); Cipher cipher;//from ww w .j a v a 2s.co m try { if (Core.PROVIDER.equals(Core.SPONGEY_CASTLE)) cipher = Cipher.getInstance("Serpent/CBC/PKCS7Padding", new org.spongycastle.jce.provider.BouncyCastleProvider()); else cipher = Cipher.getInstance("Serpent/CBC/PKCS7Padding", new BouncyCastleProvider()); cipher.init(Cipher.DECRYPT_MODE, secret, new IvParameterSpec(iv)); return cipher.doFinal(encrypted); } catch (NoSuchAlgorithmException | NoSuchPaddingException e) { e.printStackTrace(); } catch (InvalidAlgorithmParameterException e) { e.printStackTrace(); } return null; }
From source file:encryption.ThreefishCrypt.java
License:Open Source License
public static byte[] encryptNoPadding(byte[] key_aes, byte[] clean) throws InvalidKeyException, BadPaddingException, IllegalBlockSizeException { SecretKey secret = new SecretKeySpec(key_aes, "Threefish-256"); Cipher cipher;/*from w ww .ja va2s . co m*/ try { if (Core.PROVIDER.equals(Core.SPONGEY_CASTLE)) cipher = Cipher.getInstance("Threefish-256/CBC/NoPadding", new org.spongycastle.jce.provider.BouncyCastleProvider()); else cipher = Cipher.getInstance("Threefish-256/CBC/NoPadding", new BouncyCastleProvider()); cipher.init(Cipher.ENCRYPT_MODE, secret, new IvParameterSpec(iv)); return cipher.doFinal(clean); } catch (NoSuchAlgorithmException | NoSuchPaddingException e) { e.printStackTrace(); } catch (InvalidAlgorithmParameterException e) { e.printStackTrace(); } return null; }
From source file:encryption.ThreefishCrypt.java
License:Open Source License
public static byte[] decryptNoPadding(byte[] key_aes, byte[] encrypted) throws InvalidKeyException, IllegalBlockSizeException, BadPaddingException { SecretKey secret = new SecretKeySpec(key_aes, "Threefish-256"); Cipher cipher;// ww w . java 2 s . c o m try { if (Core.PROVIDER.equals(Core.SPONGEY_CASTLE)) cipher = Cipher.getInstance("Threefish-256/CBC/NoPadding", new org.spongycastle.jce.provider.BouncyCastleProvider()); else cipher = Cipher.getInstance("Threefish-256/CBC/NoPadding", new BouncyCastleProvider()); cipher.init(Cipher.DECRYPT_MODE, secret, new IvParameterSpec(iv)); return cipher.doFinal(encrypted); } catch (NoSuchAlgorithmException | NoSuchPaddingException e) { e.printStackTrace(); } catch (InvalidAlgorithmParameterException e) { e.printStackTrace(); } return null; }
From source file:encryption.ThreefishCrypt.java
License:Open Source License
public static byte[] encrypt(byte[] key_aes, byte[] clean) throws InvalidKeyException, BadPaddingException, IllegalBlockSizeException { SecretKey secret = new SecretKeySpec(key_aes, "Threefish-256"); Cipher cipher;/* ww w . j av a2 s.c o m*/ try { if (Core.PROVIDER.equals(Core.SPONGEY_CASTLE)) cipher = Cipher.getInstance("Threefish-256/CBC/PKCS7Padding", new org.spongycastle.jce.provider.BouncyCastleProvider()); else cipher = Cipher.getInstance("Threefish-256/CBC/PKCS7Padding", new BouncyCastleProvider()); cipher.init(Cipher.ENCRYPT_MODE, secret, new IvParameterSpec(iv)); return cipher.doFinal(clean); } catch (NoSuchAlgorithmException | NoSuchPaddingException e) { e.printStackTrace(); } catch (InvalidAlgorithmParameterException e) { e.printStackTrace(); } return null; }