IN JAVA: Write a function that receives a sequence of ASCII characters (this can be a Java String object or an array of

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

IN JAVA: Write a function that receives a sequence of ASCII characters (this can be a Java String object or an array of

Post by answerhappygod »

IN JAVA:
Write a function that receives a sequence of ASCII characters(this can be a Java String object or an array of byte primitives,your choice), breaks it up into 3- character subsequences. Each3-character subsequence is then split into two 12-bit values. Each12-bit value will be split into two 6-bit values by the SimpleDES system. The result will be the cipher (encrypted) or plain(decrypted) text depending on which “direction” you are processing.If the input data length is not a multiple of 3 you should pad itwith null characters (0).
Demonstrate your system by encrypting and decrypting thefollowing character strings:
• ABC
• ABCD
• ABCDE
• The cat sleeps on the tree.
For example, your code may look as such:
short key = 0b010101010
byte cipher[] = encrypt(“ABC”.getBytes(), key);
byte plain[] = decrypt(cipher, key);
for (byte b : plain) {
System.out.print(b + “ “);
}
Do this for the 4 specified test strings.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply