0
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;

I really would appreciate if someone would help me Java is really no piece of cake. // Loop through the keywordAsIntArray ArrayList, putting each 'letter' of the keyword into the map. // Duplicate letters will be overridden, so the map will contain the keyword without any duplicates. for (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

Please I want to input String as keyword, then get back hex values as the encrypted code and not integers. Also Please I have more of the codes I dont really understand,am really new to Java. Please can anyone help me.

  • 1
    Possible duplicate of [Java converting int to hex and back again](https://stackoverflow.com/questions/12005424/java-converting-int-to-hex-and-back-again) – mx0 Nov 12 '18 at 17:26
  • From the question code: "all 256 ASCII characters". ASCII does not have 256 characters, it has about 95 displayable characters. – zaph Nov 12 '18 at 18:01
  • it is actually the expanded AScII which is 256 – Engr Arome Nov 12 '18 at 21:09
  • Consider: Is 0x00 an ASCII character? 0x08? – zaph Nov 13 '18 at 07:26

0 Answers0