i. What is this code used for? ii. How many bits is it using? Q4: Encryption:...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
i. What is this code used for? ii. How many bits is it using? Q4: Encryption: 1. import javax.crypto.Cipher; 2. import javax.crypto.KeyGenerator; 3. import javax.crypto.NoSuchPaddingException; 4. import javax.crypto.IllegalBlockSizeException; 5. import javax.crypto BadPaddingException; 6. import java.security.Key; 7. import java.security.Security; 8. import java security NoSuchAlgorithmException; 9. import java.security InvalidKeyException; 10. public class DESCryptoTest { 11. public static void main(String[] args) { 12. Security.addProvider(new com.sun.crypto.provider.SunJCE()); 13. try { 14. KeyGenerator kg = KeyGenerator.getInstance("DES"); 15. Key key = kg.generateKey(): 16. Cipher cipher = Cipher.getInstance("DES"); 17. byte[] data="Mana Al Reshan!".getBytes(); 19. 20. 21. 22. 23. 24. System.out.println("Original data : " +new String(data)); cipher.init(Cipher ENCRYPT_MODE, key); byte[] result = cipher.doFinal(data); System.out.println("Encrypted data: " + new String(result)) cipher.init(Cipher DECRYPT_MODE, key); bvtell original= cipher.doFinal(result): 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. System.out.println("Decrypted data: " + new String(original)); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (NoSuchPaddingException e) { e.printStackTrace(); } catch (InvalidKeyException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IllegalBlockSizeException e) { 35. 36. 37. 38. 39. 40. e.printStackTrace(); } catch (BadPaddingException e) { e.printStackTrace(); } } bod } i. What is this code used for? ii. How many bits is it using? Q4: Encryption: 1. import javax.crypto.Cipher; 2. import javax.crypto.KeyGenerator; 3. import javax.crypto.NoSuchPaddingException; 4. import javax.crypto.IllegalBlockSizeException; 5. import javax.crypto BadPaddingException; 6. import java.security.Key; 7. import java.security.Security; 8. import java security NoSuchAlgorithmException; 9. import java.security InvalidKeyException; 10. public class DESCryptoTest { 11. public static void main(String[] args) { 12. Security.addProvider(new com.sun.crypto.provider.SunJCE()); 13. try { 14. KeyGenerator kg = KeyGenerator.getInstance("DES"); 15. Key key = kg.generateKey(): 16. Cipher cipher = Cipher.getInstance("DES"); 17. byte[] data="Mana Al Reshan!".getBytes(); 19. 20. 21. 22. 23. 24. System.out.println("Original data : " +new String(data)); cipher.init(Cipher ENCRYPT_MODE, key); byte[] result = cipher.doFinal(data); System.out.println("Encrypted data: " + new String(result)) cipher.init(Cipher DECRYPT_MODE, key); bvtell original= cipher.doFinal(result): 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. System.out.println("Decrypted data: " + new String(original)); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (NoSuchPaddingException e) { e.printStackTrace(); } catch (InvalidKeyException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IllegalBlockSizeException e) { 35. 36. 37. 38. 39. 40. e.printStackTrace(); } catch (BadPaddingException e) { e.printStackTrace(); } } bod }
Expert Answer:
Answer rating: 100% (QA)
This Java code appears to be a simple example of using the DES Data Encryption Standard algorithm for encryption and decryption Heres a breakdown of t... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
4- Consider the following functions. Formulate the problem as a MOOP. f(x) = 5-x f(x) = 4-x/2 3 2 1 Find the place of the rectangle in such a way that its distance from the first curve is maximized...
-
Case Study: Quick Fix Dental Practice Technology requirements Application must be built using Visual Studio 2019 or Visual Studio 2017, professional or enterprise. The community edition is not...
-
Quality Air Conditioning manufactures three home air conditioners: an economy model, a standard model, and a deluxe model. The profits per unit are $63, $95, and $135, respectively. The production...
-
(a) Gaseous hydrogen at a constant pressure of 0.658 MPa (5 atm) is to flow within the inside of a thin-walled cylindrical tube of nickel that has a radius of 0.125 m. The temperature of the tube is...
-
Write down the dual of the maximum-flow linear program, as given in lines (29.47)(29.50) on page 860. Explain how to interpret this formulation as a minimum-cut problem.
-
Thomas Walsh was the Chief Administrative Officer of the Virginia Commonwealth University (VCU) School of Medicine. When concerns were raised about the financial management of Walshs department, VCU...
-
Starbucks prepares consolidated financial statements. Presented below are excerpts from Note 1 describing accounting policy, Note 2, and a major portion of Note 9 from Starbucks fiscal 2008...
-
Which Python data structure is constructed using the code below? a = {"a": 1, "b": 2, "c": 3}
-
Pathfinder College is a small liberal arts college that wants to improve its admissions process. In particular, too many of its incoming freshmen have failed to graduate for a variety of reasons,...
-
Ahmed also advises you that he sold a piece of vacant land at a significant loss this year. He had planned to build a rental property on the land but learned after purchasing it that it was highly...
-
Do you think that the positivity of the office space is mostly on the employer or employee
-
You're assigned a group project and asked to come up with the following bold items for the team. Desirable team behaviors and consequences for non compliance, team conflict management plan, and team...
-
Consider the 3 generators with the characteristics given in Tab. 1, they must satisfy the load requirement in Tab. 2. Unit Pmin Pmax Marginal cost ($/MWh) Min up time (h) ($) No-load cost ($) 1 30 3...
-
Managing Linux users - Some of the topics in this week's material were around managing Linux user accounts. What are some of the concerns around this and some techniques to support managing Linux...
-
Using the brand "Naked Juice.", share the the following: How does your brand create brand awareness and how recognizable is the brand? Share a digital ad or social media post. Who is the target...
-
Bad Boy Corp makes punching bags for professional and college althletes (which are sort of the same now.). Bad Boy uses ABC costing and wants to analyze the cosst of internet sales processing and...
-
Show that, given a maximum flow in a network with m edges, a minimum cut of N can be computed in O(m) time.
-
Find the value of RL in the network in figure for maximum power transfer. Vx +. ww RL 4 Vx
-
The switch in the circuit in figure has been closed for a long time and is opened at t = 0. Find i(t) for t > 0 using Laplacetransforms. 12 V i(t) 1 F 2H +) 12 V
-
Find vo(t), t > 0, in the circuit infigure. 30 2H +. 24 V (+ 402 (1)a +)12V
-
The day after the incident described in Problem 44, the instructor finds herself in the same situation. This time, she tries a harder physics exercise. She keeps running at a constant \(6.0...
-
The \(x\) component of the velocity of a car changes from \(-10 \mathrm{~m} / \mathrm{s}\) to \(-2.0 \mathrm{~m} / \mathrm{s}\) in \(10 \mathrm{~s}\). (a) Is the car traveling in the positive or...
-
(a) A car is speeding up in the negative \(x\) direction. In what direction do \(\vec{a}\) and \(\vec{v}\) point? (b) To which of the four graphs in Figures 3 . 2 and 3 . 3 does the situation...
Study smarter with the SolutionInn App