请给我一个公平的密码,它将字符串输入转换为整数,但是我要十六进制

时间:2018-11-12 16:16:02

标签: string integer hex

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;

This is the public class
public class Process {

    private String keywordAsString = "";
    private String keyword = "";

    // ArrayList to hold the letters of the keyword with duplicates removed.
    private ArrayList<Integer> keywordAsIntsNoDup = new ArrayList<Integer>(0);

    // Map for removing all duplicate letters in the keyword.
    private Map<Integer, Integer> keywordLetters = new LinkedHashMap<Integer, Integer>(0);

    // ArrayList to hold all 256 ASCII characters (as integers).
    private ArrayList<Integer> asciiArray = new ArrayList<Integer>(0);

    // ArrayList for storing the message from the file.
    ArrayList<Integer> fileMessageAsInteger = new ArrayList<Integer>(0);

    // Constructor
    public void process() {

    }

    public void processKeyword(String keyword) {

        // Copy incoming keyword String
        this.keywordAsString = keyword;

        // Pass incoming keyword String to the removeDuplicate method.
        // removeDuplicate will first convert the letters to Integers,
        // then remove any duplicate letters.
        // Store the result in the keywordAsIntsNoDup ArrayList
        this.keywordAsIntsNoDup = removeDuplicates(this.keywordAsString);

        // Create ArrayList and fill it with all 256 ASCII characters (as integers).
        createAsciiArr();

        // Remove the keyword letters from the asciiArray. 
        for (int i=0; i<this.keywordAsIntsNoDup.size(); i++) {
            Integer letterToSearchFor = this.keywordAsIntsNoDup.get(i);
            if (this.asciiArray.contains(letterToSearchFor))
            {
                this.asciiArray.remove(letterToSearchFor);
            }
        }
    }// END processKeyword()


    public ArrayList<Integer> removeDuplicates(String keyword) {

        // Copy incoming keyword String
        this.keyword = keyword;

如果有人能帮助我,我真的很感激Java真的不是小菜一碟。             //遍历keywordAsIntArray ArrayList,将关键字的每个“字母”放入地图中。             //重复的字母将被覆盖,因此地图将包含没有重复的关键字。             为(int i = 0; i

        // Put the maps' key set (which holds the 'letters') into an ArrayList.
        // This will make it easier to put the 'letters' into the Table later.
        ArrayList<Integer> keyslist = new ArrayList<Integer>(this.keywordLetters.keySet());
        System.out.println("\n" + "map.keySet() from keyslist ArrayList = " + keyslist.toString());

        return keyslist;
    }

    public void createAsciiArr() {

        // Use an enhanced for loop to fill the asciiArray ArrayList
        // with all 256 ASCII characters as integers.
        for (int i=0; i<256; i++) {
            this.asciiArray.add(i);
        }
    }// END createAsciiArr()
}// END class

请输入String作为关键字,然后返回十六进制值作为加密代码而不是整数。还请我有更多我不真正理解的代码,这对Java来说真的很新。请任何人能帮助我。

0 个答案:

没有答案