Hello, please help me with the following question, below is the code for the tutorial
provided for us is the following tutorial and the code in
java
http://tutorials.jenkov.com/java-cryptography/index.html
https://docs.google.com/document/d/1_xZ09sbNjy9BCjgQhZrrRop4UrtXmUk2yKwSghIe1Cs/edit?fbclid=IwAR3ATn39Jm9odLYtvvndhDR6NQTZGb9yiiSpAamDwTwj5Hyk0B-cVraMqOw
, thank you for your help in advance,
Create a Java program based on the Java Cryptography API to do the following:
please find the java program written below :
--------------------------------------------------------------------------------------------------------
import java.util.*;
import java.io.*;
import java.security.*;
//importing security packages
import javax.crypto.*;
import javax.crypto.spec.SecretKeySpec;
public class test {
static final String ALGORITHM =
"AES";
//defining that we will use AES algorithm
static final String TRANSFORMATION = "AES";
public static void main (String[] args)
{
InputReader in = new
InputReader(System.in); //creating
input reader
PrintWriter w = new
PrintWriter(System.out); //creating
writer
System.out.println("please enter your name :
"); //taking username as
input
String name =
in.nextLine();
System.out.println("Please enter the input file name : ");
File inputFile = new
File(in.nextLine());
System.out.println("Enter the password for secret
key"); //taking password input
for key
//using make key method
for using password as key with some manupulation
String key =
makeKey(in.nextLine());
File encryptedFile =
new File("encrypted.txt");
File decryptedFile = new
File("decrypted.txt");
encryptWithAES(key,
inputFile, encryptedFile);
decryptWithAES(key, encryptedFile, decryptedFile);
w.close();
}
//defining encrypt method
public static void encryptWithAES(String key,
File inputFile, File outputFile) {
doCrypto(Cipher.ENCRYPT_MODE, key, inputFile, outputFile);
}
//defining decrypt method
public static void decryptWithAES(String key,
File inputFile, File outputFile) {
doCrypto(Cipher.DECRYPT_MODE, key, inputFile, outputFile);
}
//making key from given password
public static String makeKey(String pass)
{
while (pass.length()
< 16) {
pass += pass;
}
return pass.substring(0,
16);
}
//function for encryption and decryption
public static void doCrypto(int cipherMode,
String key, File inputFile, File outputFile) {
try {
//taking secret key and algorithm to be used
Key secretKey = new SecretKeySpec(key.getBytes(), ALGORITHM);
Cipher cipher = Cipher.getInstance(TRANSFORMATION);
cipher.init(cipherMode, secretKey);
//getting input file stream
FileInputStream inputStream = new FileInputStream(inputFile);
byte[] inputBytes = new byte[(int) inputFile.length()];
inputStream.read(inputBytes);
//creating output byte stream
byte[] outputBytes = cipher.doFinal(inputBytes);
//creating output file from output byte stream
FileOutputStream outputStream = new
FileOutputStream(outputFile);
outputStream.write(outputBytes);
inputStream.close();
outputStream.close();
}
//throwing exception if
error occurs
catch
(NoSuchPaddingException | NoSuchAlgorithmException
| InvalidKeyException | BadPaddingException
| IllegalBlockSizeException | IOException ex) {
System.out.println("Error encrypting/decrypting file: " +
ex);
}
}
}
-------------------------------------------------------------------------------------------------------------------
please find the screenshots of code, its execution along with different input and output files :





Hello, please help me with the following question, below is the code for the tutorial provided fo...
In this assignment you will practice using Data Structures and Object Oriented concepts in Java. Your implementation should target the most efficient algorithms and data structures. You will be graded based on the efficiency of your implementation. You will not be awarded any points if you use simple nested loops to implement the below tasks. You should use one or more of the below data structures: - ArrayList : - JavaDoc: http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html - Tutorial: http://docs.oracle.com/javase/tutorial/collections/interfaces/list.html Question You are provided with...
Java code. Need help with either 1. or 2. Nothing too
complicated and the code needs at least one loop and 3 switch
statements!
Artificial Intelligence elements in programming. Creating stories with user input. For this assignment, you can do one of two things 1. Create a chat box that allows a conversation to go on as long as the user wants . Welcome the user when they start. . look for key words or other things that could guide...
Please help me with this Java problem. Would greatly appreciate comments in the code as well: Define a class called Counter whose internal "count" variable is a basic integer counter. This class track that count from its instantiation in the constructor (can be set to any positive integer, or 0). The count should never be allowed to be negative. Include methods that will set the counter to 0, increase the count by 1, and decrease the count by 1. Include...
I need help with my javascript project, I've started on it but I can't seem to get ym java scripts to work with my index.html. Can someone please help me fix my code? I need the main.js & scratchpad.js to work with my index.html .Thank you Directions: Go to the following link: https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/JavaScript_basics On that page, scroll down to "A 'hello world' example". Follow the step-by-step instructions to download their code and edit it in your text editor of choice....
8.16 Ch 8, Part 1: XOR Cipher Write this program using Eclipse. Comment and style the code according to CS 200 Style Guide. Submit the source code files (.java) below. Make sure your source files are encoded in UTF-8. Some strange compiler errors are due to the text encoding not being correct. This program will implement a simple XOR cipher on an integer array, where the data to be encoded is XOR'd with a key. This idea is often used...
Java Project Requirements: Account class Superclass Instance variables clearPassword String Must be at least 8 characters long encryptedPassword : String key int Must be between 1 and 10(inclusive) accountId - A unique integer that identifies each account nextIDNum – a static int that starts at 1000 and is used to generate the accountID no other instance variables needed. Default constructor – set all instance variables to a default value. Parameterized constructor Takes in clearPassword, key. Calls encrypt method to create...
Hello Sir/Madam, could you please help me for the code to write UNO CARD GAME using following elements using JAVA Language: 1. Use of at least three Abstract Data Types 2. Use of inheritance and polymorphism 3. Use of recursion 4. Connection and use of a simple database 5. At least one sorting algorithm 6. At least one search algorithm 7. Use of a graphical user interface. Thank you in advance!
Chapter 06 Applied Cryptography 1. How is integrity provided? A. Using two-way hash functions and digital signatures B. Using one-way hash functions and digital signatures C. By applying a digital certificate D. By using asymmetric encryption 2. Which term refers to the matching of a user to an account through previously shared credentials? A. Nonrepudiation B. Digital signing C. Authentication D. Obfuscation 3. Which term refers to an arranged group of algorithms? A. Crypto modules B. Cryptographic service providers (CSPs)...
Please help with writing this code. The language is C++. I'm
using vim. Thanks
Problem Statement A good password has many requirements. Humans have a hard time meeting these requirements left to their own devices. You are tasked with creating a program that will generate a password based on what the user wants in the password The user should be able to choose if they want a password with: letters upper case "lower case *numbers The user should also provide...
JAVA Problem: With the recent news about data breaches and different organizations having their clients’ information being exposed, it is becoming more and more important to find ways to protect our sensitive data. In this program we will develop a simple tool that helps users generate strong passwords, encrypt and decrypt data using some cyphering techniques. You will need to create two classes. The first class is your driver for the application and contains the main method. Name this class...