Press on the image to return to the main documentation page.
Encryption
Written by Andrew Graham
This library implements various encryption and encoding methods
The following objects are available:
Base64: used to encode and decode data in Base64 representation. Cipher: used for encrypting/decrypting data. KeyGenerator: used to generate and mainpulate secret keys for symmetric ciphers. MAC: (Message Authentication Code) used generate secret key encrypted message digests. MessageDigest: used to calculate the message digest (hash) of specified data. SecureRandom: used to generate pseudo-random numbers. Signature: are used to sign data and verify digital signatures.
More information is given on each object in its help comments.
These comments are intended to document the facilities provided by this library. They are not intended in any way to cover their practical use. It is assumed that you know what you are doing when you use this library.
Documentation on the Java Cryptography Architecture may be found here.
A list of standard names used in the Java Cryptography Architecture may be found here.
Any implementation does not neccessarily include the complete list. A list of included Service Providers may be obtained with the Cipher.GetServices method and they may be passed individually to Cipher.GetAlgorithms to get the list of supported algorithms for that provider.
This object provides the functionality of a secret (symmetric) key encryptor and decryptor. The algorithms may commonly be one of the following, there are others not listed here.
AES also known as Rijndael is a 128-bit block cipher supporting keys of 128, 192, and 256 bits. DES The Digital Encryption Standard as described in FIPS PUB 46-3. DESede Triple DES Encryption (also known as DES-EDE, 3DES, or Triple-DES).
This object provides the functionality of a secret (symmetric) key generator. KeyGenerator objects are reusable, i.e., after a key has been generated, the same KeyGenerator object can be re-used to generate further keys.
Algorithm may commonly be one of the following, there are others not listed here. AES also known as Rijndael is a 128-bit block cipher supporting keys of 128, 192, and 256 bits. DES The Digital Encryption Standard as described in FIPS PUB 46-3. DESede Triple DES Encryption (also known as DES-EDE, 3DES, or Triple-DES).
The KeyPairGenerator is used to generate pairs of public and private keys. A key pair generator for a particular algorithm creates a public/private key pair that can be used with this algorithm.
Algorithm is commonly be the following, there may be others not listed here. * RSA The RSA encryption algorithm as defined in PRSA Public-Key Cryptography Standards .
Similar to a MessageDigest, a Message Authentication Code (MAC) provides a way to check the integrity of information transmitted over or stored in an unreliable medium, but includes a secret key in the calculation. Only someone with the proper key will be able to verify the received message. Typically, message authentication codes are used between two parties that share a secret key in order to validate information transmitted between these parties.
A MAC object is initialized for signing with a secret key and is given the data to be signed. The resulting signature bytes are typically kept with the signed data. When verification is needed, another MAC object is created and initialized with the same secret key.The data is uploaded and the signature obtained is compared with the signature provided with the message. The comparison may be made externally by comparing the signature provided with the data to that returned by Sign or the MAC object can do the comparison itself by using the Verify method with the provided signature.
Message digests are used to produce unique and reliable identifiers of data. They are sometimes called "checksums" or the "digital fingerprints" of the data. Changes to just one bit of the message should produce a different digest value.
Algorithm can be "MD2", "MD5", "SHA-1", "SHA-256", "SHA-384" or "SHA-512".
A seed is an array of bytes used to bootstrap random number generation. To produce cryptographically secure random numbers, both the seed and the algorithm must be secure. By default, instances of this class will generate an initial seed using an internal entropy source. This seed is unpredictable and appropriate for secure use. You may alternatively specify the initial seed explicitly by calling setSeed(byte[]) before any random numbers have been generated. Specifying a fixed seed will cause the instance to return a predictable sequence of numbers. This may be useful for testing but it is not appropriate for secure use.
Although it is common practice to seed Random with the current time, that is dangerous with SecureRandom since that value is predictable to an attacker and not appropriate for secure use.
Similar to a MessageDigest, a Signature provides a way to check the integrity of information transmitted over or stored in an unreliable medium and also ensures that it can be verified that it originated from the person it purports to originate from. It accomplishes this by using a private key to encode a hash of the original data and the corresponding public key of the key pair to decode and check that hash value.
A Signature object is initialized for signing with a private key and is given the data to be signed. The resulting signature bytes are typically kept with the signed data. When verification is needed, another Signature object is created and initialized for verification and given the corresponding public key. The data and the signature bytes are fed to the signature object, and if the data and signature match, the Signature object reports success.