【发布时间】:2012-11-25 02:06:07
【问题描述】:
我有一个关于使用循环检查某事物的可能排列的问题:
使用 26 槽字符数组形成加密句子。该数组包含一个随机字母表(每个字母只出现一次),原始未加密句子的每个字母都更改为该数组在其第 x 个位置的任何字母,x 是字母表中的原始字符位置。
例如,如果加密数组是 {'q','w','e','r','t',...,'m'},那么消息“abez”将成为“qwtm”,因为:
a is the 1st letter of the alphabet and the 1st slot of the array contained a 'q'
b is the 2nd letter of the alphabet and the 2nd slot of the array contained a 'w'
e is the 5th letter of the alphabet and the 5th slot of the array contained a 't'
...
我想通过检查关键字“morning”的每个排列来暴力破解加密的句子。
如何正确执行此操作?我已经写了一个方法来检查一个 char[] 是否包含在另一个 char[] 中,但是如何循环遍历 char[] 排列?
【问题讨论】:
-
以下是创建字母表所有排列的方法:stackoverflow.com/questions/361/…(我曾经链接过的最古老的问题)
-
字母表有 403291461126605635584000000 个排列。如果你想暴力破解,你需要大量的硬件。
标签: java loops encryption