I need to be able to encrypt and decrypt a message using a Polybius Square. I know how this works on paper but don't know where to start when turning it into a program. I was planning to use a hash map but I was told thats a bad way to go about it and that there are better approaches to do this...but I don't know what approaches that would be.
I've been given code to help me by my lecture from a workshop on the project but I don't 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 a lot this past while so now I am 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 sort the Polybius square right?
for(int row = 0; row < poly.length; row++) {
}
for(int col = 0; col < poly[row].length; col++) {
}
// c is the char I'm looking for
if(poly[row][col] == c){
}
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 obviously? what do I do then? Is the method encrypt in the Java runtime library 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