I want to encrypt this method
user enter the key word that they want
example key word=security
so the ciphertext is
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
s e c u r i t y a b d f g h j k l m n o p q v w x z
example want to encrypt "love"
so love will be "qtwr"
I do the code but still have an error
int k = 0;
String out = " ";
String keys = JOptionPane.showInputDialog("Enter the key word that you want");
int key1 = Integer.parseInt(keys);
int loop2 = keys.length();
char [] arrayKey = new char[loop2];
for (int i =0; i<arrayKey.length; i++)
{
arrayKey[i] = keys.charAt(substring(1, i));
}
// declare 26 new array
int [] arrayNew = new int [26];
for(int i=0; i<arrayNew.length; i++)
{
if (arrayKey[i] != "")
{
arrayNew[i] = arrayKey[i];
}
else
{
arrayNew[i] = characters[k];
k =k+1;
}
}
//print answer
for (int i=0; i<arrayNew.length; i++)
{
out = out + arrayNew[i];
}
JOptionPane.showMessageDialog(null,out);

New Topic/Question
Reply



MultiQuote





|