I need to be able to encrypt and decrypt a message using a Polybius Square, I know how this works on paper but dont know where to start when turing it into a program. I was planning to use a hashmap but I was told thats a bad way to go about it and that theres better approuchs to do this that are easier... like what?
I've been given code to help me by my lecture from a workshop on the project but I dont fully understand it. I'll paste it below and if anyone could explain it I would greatly appreciate it! I've been focusing on C alot this past while so now im a bit rusty when it comes to Java.
char [][] poly = {{",'A','B','D'.....
{'A','P','H','Q'}
}
Thats a double array that I'll be using to stort the Polybius square right?
for(int row = 0; row<poly.length,row++){}
for(int col = 0; col<poly[row].length,col++){}
if(poly[row][col] = MyChar That Im Looking For){
}
This is used for navigating the array and finding the chars I want?
// how to break a line down to a character
String[] words = line.split(" ");
for(int i=0; i < words.length; i++){
String word = words[i];
for(int j = 0; j <word.length(); j++){
char letter = word.charAt(j);
encrypt(letter);
}
}
This is breaking a line down to letters ovbiously? what do I do then? also is the method encrypt in the java lib or do I have to make my own somehow?
I'm not sure where to begin or what would be the best way to go about this, I think I might just watch hash map tutorials and try that? This is my first time trying encryption and the whole thing looks hard and intimidating.
Aucun commentaire:
Enregistrer un commentaire