我已经阅读了使用Java来加密整数和使用DES使用Pass Phrase加密.
我需要的只是一个简单的加密器,它将12位数字转换为12位数字,具有以下约束:
通过文献搜索我有这个代码与我
public void mytestSimple(long code, String password) throws Exception {
SecretKey key = new SecretKeySpec(password.getBytes(), "DES");
Cipher ecipher = Cipher.getInstance("DES");
ecipher.init(Cipher.ENCRYPT_MODE, key);
System.out.println(ecipher.getOutputSize(8));
byte[] encrypted = ecipher.doFinal(numberToBytes(code));
System.out.println(encrypted + "--" + encrypted.length);
Cipher dcipher = Cipher.getInstance("DES");
dcipher.init(Cipher.DECRYPT_MODE, key);
byte[] decrypted = dcipher.doFinal(encrypted);
System.out.println(bytesToNumber(decrypted) + "--" + decrypted.length);
}
public void testSimple() throws Exception {
mytestSimple(981762654986L, "password");
}
Run Code Online (Sandbox Code Playgroud)
我遇到了问题
****我在下面添加的答案****
我添加了一个答案,即从标准Java RSA密钥对逻辑中提取的40位RSA.我仍然需要研究边缘情况.我将接受答案并提出"Tadmas",我认为有点引导我回答.有人能告诉我我的算法是否会变弱/可攻击吗?