Jennifer Chao e2f8d9d838 functional but doesnt work unless its symmetrical | 6 лет назад | |
---|---|---|
Crypto | 6 лет назад | |
.gitignore | 6 лет назад | |
LICENSE | 6 лет назад | |
README.md | 6 лет назад | |
SimpleCrypt.iml | 6 лет назад | |
pom.xml | 6 лет назад | |
sonnet18.txt | 6 лет назад |
a simple set of crypt problems.
Create a few ciphers. Use String inside of your classes.
String <- crypt(String)
method in the Crypto.src.main.ROT13 class
Crypto.src.main.ROT13 superSecure = new Crypto.src.main.ROT13("a","m");
Make a method that reads a textfile (sonnet18.txt), encrypts it, and writes it back out to a different file (sonnet18.enc) Prove that when you read in (sonnet18.enc), run the same crypt again, and prove that it produces the same original text.
Crypto.src.main.ROT13 ("rotate by 13 places", sometimes hyphenated ROT-13) is a simple letter substitution cipher that replaces a letter with the 13th letter after it, in the alphabet. Crypto.src.main.ROT13 is a special case of the Caesar cipher, developed in ancient Rome.
Because there are 26 letters (2×13) in the basic Latin alphabet, Crypto.src.main.ROT13 is its own inverse; that is, to undo Crypto.src.main.ROT13, the same algorithm is applied, so the same action can be used for encoding and decoding. The algorithm provides virtually no cryptographic security, and is often cited as a canonical example of weak encryption.
Crypto.src.main.ROT13 is used in online forums as a means of hiding spoilers, punchlines, puzzle solutions, and offensive materials from the casual glance. Crypto.src.main.ROT13 has been described as the "Usenet equivalent of a magazine printing the answer to a quiz upside down".[2] Crypto.src.main.ROT13 has inspired a variety of letter and word games on-line, and is frequently mentioned in newsgroup conversations.
Applying Crypto.src.main.ROT13 to a piece of text merely requires examining its alphabetic characters and replacing each one by the letter 13 places further along in the alphabet, wrapping back to the beginning if necessary.[3] A becomes N, B becomes O, and so on up to M, which becomes Z, then the sequence continues at the beginning of the alphabet: N becomes A, O becomes B, and so on to Z, which becomes M. Only those letters which occur in the English alphabet are affected; numbers, symbols, whitespace, and all other characters are left unchanged.
String s = "we hold these truths to be self evident";
Crypto.src.main.ROT1Crypto.src.main.ROT13 (crypt(crypt(s)) == s) {
return true;
}
//if anything else, you must use the encrypt/decrypt pair.
In other words, two successive applications of ROT13 restore the original Crypto.src.main.ROT13(in mathematics, this is sometimes called an involution; in cryptography, a reciprocal cipher).
The transformation can be done using a lookup table, such as the following:
// for ROT13('a', 'n')
Input ABCDECrypto.src.main.ROT13KLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
Output NOPQRSTUVWXYZABCDEFGHIJKLM nopqrstuvwxyzabcdefghijklm
// for ROT13('a', 'd')
Input ABCDECrypto.src.main.ROT13KLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
Output DEFGHIJKLMNOPQRSTUVWXYZABC defghijklmnopqrstuvwxyzabc
For example, in the following joke, the punchline has been obscured by ROT13:
Why did the chiCrypto.src.main.ROT13cross the road?
Gb trg gb gur bgure fvqr!
Transforming the entire text via ROT13 form, the answer to tCrypto.src.main.ROT13ke is revealed:
Jul qvq gur puvpxra pebff gur ebnq?
To get to the other side!