|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecthcrypto.cipher.Cipher
public class Cipher
Provides the functionality for a wide range of historical ciphers that can be used for encryption and decryption.
To create a Cipher object, the application must call Cipher.getInstance() passing it a String that gives the name of the cipher algorithm. For example, here is how one would create a Caesar cipher.
Cipher cipher = Cipher.getInstance("Caesar");
HistoricalKey key = HistoricalKey.getInstance("Caesar", cipher.getProvider());
key.init("55/printable");
cipher.init(key);
String c1encrypt = cipher.encrypt(secret);
The Cipher.getInstance() method searches a list of providers for an
implementation of Caesar cipher and will throw a "No such algorithm"
exception if none is found. Details on creating an algorithm-dependent
key for the cipher are described in the documentation of
HistoricalKey class.
See also:
CipherEngine
HistoricalKey
Provider
| Method Summary | |
|---|---|
java.lang.String |
decrypt(java.lang.String s)
decrypts its String parameter returning the plaintext string. |
void |
decryptFile(java.lang.String inFileName,
java.lang.String outFileName)
decrypts a ciphertext input file into an output file by simply calling the engineDecryptFile() method implemented in the ENGINE. |
void |
decryptFile(java.lang.String inFileName,
java.lang.String outFileName,
java.lang.String encoding)
decrypts a ciphertext input file into an output file by simply calling the engineDecryptFile() method implemented in the ENGINE. |
java.lang.String |
encrypt(java.lang.String s)
encrypts its String parameter returning the encrypted string. |
void |
encryptFile(java.lang.String inFileName,
java.lang.String outFileName)
encrypts a plaintext input file into an output file by simply calling the engineEncryptFile() method implemented in the ENGINE. |
void |
encryptFile(java.lang.String inFileName,
java.lang.String outFileName,
java.lang.String encoding)
encrypts a plaintext input file into an output file by simply calling the engineEncryptFile() method implemented in the ENGINE. |
java.lang.String |
getAlgorithm()
returns a string giving the name of the cipher algorithm. |
java.lang.String |
getAlphabetRangeOptions()
returns a string giving the alphabet range options for a particular cipher. |
static Cipher |
getInstance(java.lang.String algorithm)
searches for a provider that provides an implementation of the algorithm named in its parameter, throwing a "no such algorithm" exception if none is found. |
static Cipher |
getInstance(java.lang.String algorithm,
java.lang.String provider)
searches for the provider named in the second parameter for an implementation of the algorithm named in its first parameter. |
java.lang.String |
getProvider()
returns a string giving the name of the provider that implements the cipher algorithm. |
void |
init(HistoricalKey key)
initializes the particular encrypting engine by calling the encapsulated CipherEngine and passing it a key of the appropriate type. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static final Cipher getInstance(java.lang.String algorithm,
java.lang.String provider)
algorithm, - a String giving the algorithm nameprovider, - a String giving the provider namepublic static final Cipher getInstance(java.lang.String algorithm)
algorithm, - a String giving the algorithm name
public final void init(HistoricalKey key)
throws java.lang.Exception
key, - an instance of a HistoricalKey
java.lang.Exception
public final void encryptFile(java.lang.String inFileName,
java.lang.String outFileName)
throws java.lang.Exception
inFile, - the name of the input plaintext file.outFile, - the name of the output encrypted file.
java.lang.Exception
public final void encryptFile(java.lang.String inFileName,
java.lang.String outFileName,
java.lang.String encoding)
throws java.lang.Exception
inFile, - the name of the input plaintext file.outFile, - the name of the output encrypted file.encoding, - the name of the encoding scheme -- "ISO-2022-JP"
java.lang.Exception
public final void decryptFile(java.lang.String inFileName,
java.lang.String outFileName)
throws java.lang.Exception
inFile, - the name of the input ciphertext file.outFile, - the name of the output plaintext file.
java.lang.Exception
public final void decryptFile(java.lang.String inFileName,
java.lang.String outFileName,
java.lang.String encoding)
throws java.lang.Exception
inFile, - the name of the input ciphertext file.outFile, - the name of the output plaintext file.encoding, - the name of the encoding scheme -- e.g., "ISO-2022-JP"
java.lang.Exception
public java.lang.String encrypt(java.lang.String s)
throws java.lang.Exception
s, - a String to be encrypted
java.lang.Exception
public final java.lang.String decrypt(java.lang.String s)
throws java.lang.Exception
s, - a String to be decrypted
java.lang.Exceptionpublic final java.lang.String getAlgorithm()
public final java.lang.String getProvider()
public final java.lang.String getAlphabetRangeOptions()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||