如何获取多维数组的原始索引以解密Polybius密码

时间:2019-07-28 12:41:56

标签: java encryption multidimensional-array

我正在尝试解密波利比乌斯广场。

我已经具有可以使用的加密功能,只是无法解密它。

到目前为止,我有这个:

公共类矩阵{

    public char[][] cypher = {
        {'p', 'h', '0', 'q', 'g', '6'}, 
        {'4', 'm', 'e', 'a', '1', 'y'}, 
        {'l', '2', 'n', 'o', 'f', 'd'},
        {'x', 'k', 'r', '3', 'c', 'v'}, 
        {'s', '5', 'g', 'w', '7', 'b'}, 
        {'j', '9', 'u', 't', 'i', '8'},};


         private char [] encryptionValues = {
         'A', 'D', 'F', 'G', 'V', 'X' 
         };

public  String getEncryptedCharacters(char plain) {
    for (int row = 0; row < cypher.length; row++){
        for (int column = 0; column < cypher[row].length; column++){
            if (cypher [row][column] == plain){
                char rowValue = encryptionValues [row];
                char columnValue = encryptionValues [column];
                String result = new String ();
                result = "" + rowValue + columnValue;
                return result;
            }
        }
    }
    return "!!";

}

我该如何扭转呢?到目前为止,我已经尝试过了:

    public  String getDecryptedCharacter(char ciphertext, char 
     encryptionvalues) {
       for (int column = 0; column < cypher.length; column++){
          for (int row = 0; row < cypher[column].length; row++){
            if (cypher  [row] [column] == ciphertext){
              char  rowValue = encryptionValues [row];
                char  columnValue = encryptionValues [column];
                String result = new String ();
                result = "" + rowValue + columnValue;
                return result;
            }
        }
    }
    return "!";
            }

}

0 个答案:

没有答案