|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectapplications.FileCipher
public class FileCipher
A command-line program to test the installation of the HcryptoJ API. The following example command lines show how to compile and run the program. It assumes that the hcrypto.jar file is located 2 directory levels above the directory containing this program, which is the default hierarchy of HcryptoJ.
In the following example, a Caesar cipher with a shift of 4 and an
alphabet of 'a' to 'z' is being used to encrypt or decrypt
the infile producing the outfile as a result.
To compile: javac -classpath ../../hcrypto.jar:. FileCipher.java
To run: java -classpath ../../hcrypto.jar:. FileCipher Caesar \
4/az/az -e|-d infile outfile [encoding]
MODIFICATION v1.3: HcryptoJ can specify different alphabets for the input and output message. This requires a revised key specification. The second alphabet is optional. So the following specification for a Caesar cipher is still valid: 4/az. But the following specifications are also valid:
Caesar 4/az/az
Caesar 4/az+AZ/az+AZ
Caesar 4/printable+UnicodeBlock.HIRAGANA/printable+UnicodeBlock.HIRAGANA
For details on the allowable specifications, see AlphabetFactory.java.
MODIFICATION v1.3: This program has been modified to accept files with alternative Unicode 1.1 encodings. These can be specified by the optional command-line encoding parameter. An example would be the file testfiles/iso-2022-jp, which uses an ISO-2022-JP encoding.
FileCipher can encrypt the Hiragana characters in this file by using the following command line:
java -classpath ../../classes:. FileCipher Caesar \
4/UnicodeBlock.HIRAGANA/UnicodeBlock.HIRAGANA -e \
testfile etestfile ISO-2022-JP
FileCipher can encrypt the printable ascii and the Hiragana characters using the following command line:
java -classpath ../../classes:. FileCipher Caesar \
1/printable+UnicodeBlock.HIRAGANA/printable+UnicodeBlock.HIRAGANA -e iso-2022-jp \
iso-2022-jp.enc ISO-2022-JP
The program CreateUnicodeFile.java enables you to create a small file that uses ISO-2022-JP encoding. Here's an example of how it can be used:
$ java CreateUnicodeFile // creates a ISO-2022-JP file called testfile
$ java -classpath ../../classes:. FileCipher Caesar \
1/UnicodeBlock.HIRAGANA/UnicodeBlock.HIRAGANA -e testfile etestfile \
ISO-2022-JP
$ java -classpath ../../classes:. FileCipher Caesar \
1/UnicodeBlock.HIRAGANA/UnicodeBlock.HIRAGANA -d etestfile detestfile \
ISO-2022-JP
The files testfile and detestfile should be equivalent.
| Constructor Summary | |
|---|---|
FileCipher()
|
|
| Method Summary | |
|---|---|
static void |
main(java.lang.String[] args)
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FileCipher()
| Method Detail |
|---|
public static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||