我已经阅读了使用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",我认为有点引导我回答.有人能告诉我我的算法是否会变弱/可攻击吗?
我正在尝试使用P4J获取目录上的更改列表.这是我用过的片段,
P4JServer server = //get a valid server using username/pwd
List<P4JFileSpec> fileSpec = P4JFileSpecBuilder.makeFileSpecList(new String[]{"//depot/se/mydir"}); //a valid directory
if(P4JFileSpecBuilder.getValidFileSpecs(fileSpec).isEmpty()) {
throw new RuntimeException("File spec invalid for [" + depotPath + "]");
}
List<P4JChangeList> changes = server.getChangeLists(10, fileSpec, null, null, true, true, false, true);
System.out.println(changes.size()); //prints 0 here
Run Code Online (Sandbox Code Playgroud)
但是,如果我使用"// depot/se/myfile"这是一个有效的文件,则打印更改列表.难道我做错了什么?我需要一个目录上的变更列表.
Python 2.7.1
我想明白为什么我不能做以下似乎是明智的事情
def do_stuff():
# return a function which takes a map as an argument and puts a key in there
f = lambda map: map['x'] = 'y' #compilation error
return f
x = do_stuff()
map = {}
x(map)
print map['x']
Run Code Online (Sandbox Code Playgroud)
我可以让lambda函数变得更简单,f = lambda map: os.path.exists但是我不能让它改变地图.谁能告诉我如何实现这一目标?如果这根本不可能,为什么?
日食3.7
这与How do I stop Eclipse fromfreshing some dir?无关。因为我可以在启动时刷新 Eclipse 项目。
我的项目源位于网络驱动器中(我需要在 Windows 中使用 Eclipse 并在 Linux 中运行代码)。Eclipse 会定期冻结,我相当确定这是因为 Windows 正在疯狂地尝试访问 NAS 区域,而且速度很慢。我不会在 Eclipse 之外更改源文件,因此我不需要 Eclipse 中的功能,例如在后台更改文件时刷新文件。
问题