变位密码解密而不知道密钥

时间:2019-12-02 17:57:36

标签: java cryptography

我试图在没有密钥的情况下解密传输密码。我所知道的是4到6位数字之间的密钥。到目前为止,我已经尝试了蛮力方法,并开发了一些代码将消息分成4-6个相等的部分。我知道这些子消息需要进行连接(每个消息中的第一个字母,然后第二个字母,等等),但是我不知道如何实现代码,以便它可以完成所有组合。

这是我到目前为止的代码:

import java.util.ArrayList;

/**
 * Write a description of class Main here.
 *
 * @author (your name)
 * @version (a version number or a date)
 */
public class Main
{
    // instance variables - replace the example below with your own
    private String message;
    private String first;
    private int x;
    private int kLength;
    //private ArrayList<String> messageArr;

    /**
     * Constructor for objects of class Main
     */
    public Main()
    {
        // initialise instance variables
        message ="RIOEDSALEWENILUCNHHUEEDHEHAETRWRETHESWTIIGHWEGLUNASEMVLHHIUEEPITOAOOOANCETDNSENAWESSNGHCRNONFHLOERNRRAONRNAROANOSEASNTAEHCEFIRHENYSEESEFSLCSAMIYSDTNLWTMSHHIGDNEPGTONSARVAHDRELACUBNSATREDAELWENTSPNEDEORABDNRNLTDFLUYTWFDDIRDLETROAERSCIEOESPSCAORHERIAUPCMIHBHUEEIEDOOIEESBDNPTSNSNURVWHRSBPEDCRIRSSDAEOEDPGWALKFEDTOCODOGFTPTITLRNTIHNOEHARTOCTECWSFHLWELHWCPETOSHUIIHAWOECBEDCPSHOTSTGENEEEOAGURRNARWESEDNLAGIOTEWSARWALREGIDOHGUERAEAITRNWSLWAEFTDDETNEFBTTFEYMOELEDSRSIANORTEOWNEASCNOREDSEOEFTAGNGEHTOHERRSELNTWTITUVDCPOIBHTISEHMHTTWITHEINHIAWUNEDFMINOSUAHWUETRSLHYOIACADHUOEFNNERIFSILSTHIOEKELHLDDWAAFNRLAOEPEHTWSBPESINBRDAORBNDLONTBSNEETJNNSSEHYTITBBSETCHLRETYTLKIOAFHNSTDEANLNCESIBHFPTMLTATTWSUCOSIRWLMDRIIHOAEEVIEYTEAANTNEEHIFTIOHBAAFERAHITEEROTECMARGHLTANDMTGMELTDHEMOOEWPSONBENFSFGDSTSTLNAAHONFHISEEOHTICGBKITLWSPNEHEHEUDBNGEIILFKRGUYAIOAAGEO";
        kLength = 5;
        first = "";
        x = 0;
        ArrayList<String> messageArr = new ArrayList<String>();

        for (int i = 0; i<kLength; i++){
            while(x<(message.length()/kLength)*(i+1))
            {
                int index = (x);
                first = (new StringBuilder()).append(first).append(message.charAt(index)).toString();
                x++;
            }
            messageArr.add(first);
            first = "";
        }
        PrintArr(messageArr);
        Combine();
    }

    private void PrintArr(ArrayList<String> messageArr)
    {
        System.out.println("");
        for (String num : messageArr)
        {
            System.out.println(num);
        }
    }

    private void Combine()
    {
        int a = 0;
        while(a < message.length())
        {

        }
    }
}

是最好的方法,还是还有另一种方法?那我从这里去哪里呢? 任何帮助将不胜感激!

0 个答案:

没有答案