Question: WOULD YOU PLEASE BE ABLE TO FIX THIS PROGRAM. (BITWISE OPERATION (cryptography) (JAVA) BELOW IS THE QUESTION/MY PROGRAM/THE ERRORS Question- Implement the encryption function discussed
WOULD YOU PLEASE BE ABLE TO FIX THIS PROGRAM. (BITWISE OPERATION (cryptography) (JAVA)
BELOW IS THE QUESTION/MY PROGRAM/THE ERRORS
Question-
Implement the encryption function discussed in class. Do NOT use ANY string manipulation or arithmetic functions to implement your solution.
Test that input 0xADE1 yields ciphertext (188, 153). You may hard-code these values for testing.
the program I made-
public class String algo
{
public static void main(String []args){
String algo = "OxADE1" ;
SecretKeyFactory skf = SecretKeyFactory.getInstance(algo);
SecretKey key = skf.generateSecret(ks);
Cipher c = Cipher.getInstance(algo);
c.init(Cipher.ENCRYPT_MODE, key);
}
}
The errors-
You have a number of bugs in your code.
- SecretKeyFractory.getInstance is being passed the algorithm string "OxADE1" however, that is not a valid algorithm name. It will throw a NoSuchAlgorithmException.
- ks, the KeySpec is not defined.
- Cipher.getInstance is also being passed the algorithm string "OxADE1" however, that is not a valid algorithm name. It will also throw a NoSuchAlgorithmException.
0xADE1 happens to be the plaintext, not the algorithm name. You use an algorithm (the one that was mentioned in class which you didn't mention here) to encode the plaintext into a ciphertext using a SecretKey. This SecretKey can be used to decrypt the ciphertext back into the plaintext using thealgorithm.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
