Pages

This tutorial covers the basics of the science of cryptography. It explains how programmers and network professionals can use cryptography to maintain the privacy of computer data. Starting with the origins of cryptography, it moves on to explain cryptosystems, various traditional and modern ciphers, public key encryption, data integration, message authentication, and digital signatures.

Wednesday 30 December 2015

[SOLVED] org.bouncycastle.jcajce.provider.symmetric.util.BaseBlockCipher$1: Key length not 128/192/256 bits.

SOURCE
 ----- 
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
 byte[] input = "Hello".getBytes();
 byte[] keyByte = "1234567812345678123456781234567".getBytes();
 SecretKeySpec key = new SecretKeySpec(keyByte, "AES");
----
ERROR
Dec 31, 2015 11:57:52 AM aes256.AES256 main
SEVERE: null
org.bouncycastle.jcajce.provider.symmetric.util.BaseBlockCipher$1: Key length not 128/192/256 bits.
at org.bouncycastle.jcajce.provider.symmetric.util.BaseBlockCipher.engineInit(Unknown Source)
at org.bouncycastle.jcajce.provider.symmetric.util.BaseBlockCipher.engineInit(Unknown Source)
at javax.crypto.Cipher.init(Cipher.java:1246)
at javax.crypto.Cipher.init(Cipher.java:1186)
at aes256.AES256.main(AES256.java:36)
Caused by: java.lang.IllegalArgumentException: Key length not 128/192/256 bits.
at org.bouncycastle.crypto.engines.AESFastEngine.generateWorkingKey(Unknown Source)
at org.bouncycastle.crypto.engines.AESFastEngine.init(Unknown Source)
at org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher.init(Unknown Source)
at org.bouncycastle.jcajce.provider.symmetric.util.BaseBlockCipher$BufferedGenericBlockCipher.init(Unknown Source)
... 5 more
BUILD SUCCESSFUL (total time: 1 second)
SOLUTION
Key Leng AES must 128 / 192 / 256 bit or 16 / 24 / 32 Character 
 Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
 byte[] input = "Hello".getBytes();
 byte[] keyByte = "12345678123456781234567812345678".getBytes();
 SecretKeySpec key = new SecretKeySpec(keyByte, "AES");



Tuesday 29 December 2015

Encrpt And Decrypt Using AES 256 in Java

Name Algorithm
AES 256
Type Algorithm
Block Cipher
Key Length
256 bit / 32 Character
Link Video Encrypt and Decrypt Using AES 256 in Java
https://youtu.be/NS0QBDq9PfA