hcrypto.provider
Class RamProvider
java.lang.Object
|
+--hcrypto.provider.Provider
|
+--hcrypto.provider.RamProvider
- public class RamProvider
- extends Provider
This class provides an example of programmer-defined Provider.
This provider implements a Caesar cipher. To implement any
cipher, the programmer must define an engine, which contains
the encryption algorithm, and a key, which contains the
associated key for that engine.
To use a provider in an application program, use the static
Provider.addProvider() method to add the provider
to the list of providers available to the program:
public static void main (String args[]) throws Exception {
Provider.addProvider(new DefaultProvider("Default"));
Provider.addProvider(new RamProvider("Ram"));
...
}
Once the program has the provider, its ciphers can
be used by the program as follows:
Cipher cipher = Cipher.getInstance("Caesar", "Ram");
HistoricalKey key = HistoricalKey.getInstance("Caesar", cipher.getProvider());
key.init("55/printable");
cipher.init(key);
String c1encrypt = cipher.encrypt(secret);
In this case an instance of the Caesar cipher implemented by the "Ram" provider
will be created. Note that the CaesarEngine class is a subclass of
CipherEngine and the CaesarKey class is a subclass of HistoricalKey.
See also:
DefaultProvider
DefaultProvider
CipherEngine
HistoricalKey
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RamProvider
public RamProvider(java.lang.String name)