Encryption
Encryption
Asymmetric Encryption:-
In public-key encryption schemes, the encryption key is published for anyone to use and for
encrypting messages. Only the receiving party has access to the decryption key that enables
messages to be read
Symmetric Encryption:-
In symmetric-key schemes, the encryption and decryption keys are the same.
Communicating parties must have the same key in order to achieve secure communication.
Key:-
A key is a string of characters used within an encryption algorithm for altering data so that it
appears random. Like a physical key, it locks (encrypts) data so that only someone with the
right key can unlock (decrypt) it.
In other words key is a group of random characters in a particular order. Encryption
protocols use a key to alter data so that it's scrambled, and so that anyone without the key
can't decode the information.
The original data is known as the plaintext, and the data after the key encrypts it is known as
the ciphertext.
Encryption Algorithms:-
Triple DES Encryption:-
Triple DES was designed to replace the original Data Encryption Standard (DES) algorithm,
which hackers learned to defeat with ease. At one time, Triple DES was the recommended
standard and the most widely used symmetric algorithm in the industry.
Triple DES uses three individual keys with 56 bits each. The total key length adds up to 168
bits, but experts say that 112-bits in key strength is more like it.
Though it is slowly being phased out, Triple DES is still a dependable hardware encryption
solution for financial services and other industries.
RSA Encryption:-
RSA is a public-key encryption algorithm and the standard for encrypting data sent over the
internet. It also happens to be one of the methods used in PGP and GPG programs.
Unlike Triple DES, RSA is considered an asymmetric encryption algorithm because it uses a
pair of keys. The public key is used to encrypt a message and a private key to decrypt it. It
takes attackers quite a bit of time and processing power to break this encryption code.
Class IvParameterSpec:-
It is present in javax.crypto.spec.IvParameterSpec package.
It inherits from Object class and AlgorithmParameterSpec interface.
it have also one method byte[] getIV()(Returns the initialization vector (IV))
it Returns a new array each time this method is called.
Class SecretKeySpec:-
It is present in javax.crypto.spec.SecretKeySpec package.
It inherits from Object class and KeySpec, SecretKey interface.
This class specifies a secret key in a provider-independent fashion.
It can be used to construct a SecretKey from a byte array, without having to go through a
(provider-based) SecretKeyFactory.
This class is only useful for raw secret keys that can be represented as a byte array and have
no key parameters associated with them, e.g., DES or Triple DES keys.
Tests for equality between the specified object and this object.
String getAlgorithm()
Returns the name of the algorithm associated with this secret key.
byte[] getEncoded()
String getFormat()
Returns the name of the encoding format for this secret key.
Int hashCode()
Cipher:-
It is present in javax.crypto.Cipher package.
It inherits from Object class.
This class provides the functionality of a cryptographic cipher for encryption and
decryption. It forms the core of the Java Cryptographic Extension (JCE) framework.
In order to create a Cipher object, the application calls the Cipher's getInstance method, and
passes the name of the requested transformation to it.
Every implementation of the Java platform is required to support the following standard
Cipher transformations with the keysizes in parentheses:
AES/CBC/NoPadding (128)
AES/CBC/PKCS5Padding (128)
AES/ECB/PKCS5Padding (128)
DES/CBC/NoPadding (56)
DES/CBC/PKCS5Padding (56)
DES/ECB/NoPadding (56)
DES/ECB/PKCS5Padding (56)
DESede/CBC/NoPadding (168)
DESede/CBC/PKCS5Padding (168)
DESede/ECB/NoPadding (168)
DESede/ECB/PKCS5Padding (168)
byte[] doFinal()
Int doFinal(byte[] input, int inputOffset, int inputLen, byte[] output, int
outputOffset)
String getAlgorithm()
Int getBlockSize()
ExemptionMechanism getExemptionMechanism()
byte[] getIV()
Returns the maximum key length for the specified transformation according to the
installed JCE jurisdiction policy files.
Returns the length in bytes that an output buffer would need to be in order to hold the
result of the next update or doFinal operation, given the input length inputLen (in
bytes).
AlgorithmParameters getParameters()
Provider getProvider()
Initializes this cipher with the public key from the given certificate.
Initializes this cipher with the public key from the given certificate and a source of
randomness.
Initializes this cipher with a key, a set of algorithm parameters, and a source of
randomness.
Initializes this cipher with a key, a set of algorithm parameters, and a source of
randomness.
Int update(byte[] input, int inputOffset, int inputLen, byte[] output, int
outputOffset)
Wrap a key.
--------End--------