|
JCE - Cipher - Encryption and Decryption
Part:
1
2
3
This chapter describes some parts of the JCE (Java Cryptography Extension)
which has been introduced in JDK since 1.1:
- What is a secret key?
- Classes in JDK to generate a secret key.
- Classes in JDK to write and read a secret key to and from a file.
- A sample program to generate, write, and read a secret key.
What Is a Secret Key?
A secrete key is the key used in a symmetric encryption algorithm, where
the same key is used both the encryption process and the decryption process.
Known symmetric encryption algorithms:
- Blowfish - The block cipher designed by Bruce Schneier.
- DES - The Digital Encryption Standard as described in FIPS PUB 46-2.
- DESede - Triple DES Encryption (DES-EDE).
The SecretKey Interface
javax.crypto.SecretKey is an interface providing a grouping point for
various secret keys. It extents java.security.Key, and inherits 3 methods:
getAlgorithm() - Returns the algorithm name used to generate the key.
getEncoded() - Returns the key as a byte array in its primary encoding format.
getFormat() - Returns the name of the primary encoding format of this key.
The KeyGenerator Class
javax.crypto.KeyGenerator is an abstract class providing a link to
implementation classes of secret key generration algorithms
provided by various security package providers.
Major methods in the KeyGenerator class:
getInstance() - Returns a KeyGenerator object of the specified algorithm from
the implementation of the specified provider. If provider is not specified,
the default implementation is used. This is a static method.
init() - Initializes this key generator with the specified key size.
generateKey() - Generates a key and returns it as a SecretKey object.
getAlgorithm() - Returns the algorithm name of this generator.
getProvider() - Returns the provider as a Provider object of this generator.
(Continued on next part...)
Part:
1
2
3
|