⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 caesartest.java

📁 用JAVA编写的小的JAVA程序,是有关密码转换的.有2种算法.
💻 JAVA
字号:
import junit.framework.TestCase;

/**
 * Class for testing Caesar class
 */
public class CaesarTest extends TestCase {
	
	private Cipher cipher = new Caesar();
	
	/**
	 * Testing the encryption function
	 */
	public void testEncrypt() {
		String plaintext = "geronimo";
		String ciphertext = "igtqpkoq";
		int key = 2;
		
		cipher.setIntKey(key);
		assertEquals(ciphertext, cipher.encrypt(plaintext));
	}
	
	/**
	 * Testing the decryption function
	 */
	public void testDecrypt() {
		String plaintext = "springbreak";
		String ciphertext = "hegxcvqgtpz";
		int key = 15;
		
		cipher.setIntKey(key);
		assertEquals(plaintext, cipher.decrypt(ciphertext));
	}
	
	/**
	 * Verifying encryption
	 */
	public void testEncryptDecrypt() {
		String plaintext = "karelj";
		int key = 12;
		
		cipher.setIntKey(key);
		assertEquals(plaintext, cipher.decrypt(cipher.encrypt(plaintext)));
	}

}



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -