Java AES File Encryption
May 10, 2015
I have a program that encrypts and decrypts using the AES algorithm, but I have to specify the name of the encrypted file, and also specify the format of the original file as part of the name of the encrypted file. I will like to know how how to implement the following features into my code : 1.)I want the name of the encrypted file to be in cipherText 2.) i want the computer to be able to decide the file type(extension eg.txt) without me having to specify it, for example in my code if I am encrypting a .jpg file, I have to specify the name of the encrypted file as encrypt.jpg
Here is my code which i have tried to implement:
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.CipherOutputStream;
[Code] ....
To see if I could get the file name to be in cipher text but I got these errors:
Exception in thread "main" java.lang.NullPointerException
at java.lang.String.<init>(Unknown Source)
at EncryptDecrypt.encrypt(EncryptDecrypt.java:48)
at EncryptDecrypt.main(EncryptDecrypt.java:37)
View Replies
ADVERTISEMENT
Nov 12, 2014
I am trying to create a file browse option in my jsp and later after browsing, all i want to do is to read that file in my jsp without saving it into that database so that i can perform encryption for it and save that encrypted file later into my database. please provide reference link so that i can refer to some applications and and move ahead with my work.
View Replies
View Related
Mar 8, 2014
I want to create a java program that can be encrypt-decrypt alphabet from characters . Which is the shifting of the alphabet is starting from the the first character to increase 4 and 5 increased in the second character, increasing 6 at the third character, and so on..
Then when one of the characters increasement is more than the ascii code of 'z', that character will decrease from the variable i from the loop. This is the output of the program that i want:
Encryption:
Plain text: "abcz"
Cipher text: "egiz"
Decryption:
Cipher text: "egiz"
Plain text: "abcz"
This is my code for now:
package -;
public class - {
public static void main(String[] args) {
String enkripsi = "abcz".toLowerCase();
String dekripsi = "egiz".toLowerCase();
[Code] ....
What's wrong with my code? It won't work. Specially in the decryption.
View Replies
View Related
Mar 14, 2015
I need to encrypt/decrypt file contents using RSA . But the default nature of RSA I could not upload files larger than 177 bytes for key length 1024 bytes . How it can avoid , I look it for a 100 times yet...
I attach my encryption files here ...
See attached files for more details ...
View Replies
View Related
Nov 1, 2014
I have to write an encryption/decryption program for a sentence entered by the user that uses arrays. Here is my code so far. I'm kind of lost on what to do next in the code.
import java.util.Scanner;
/*Program that encrypts then decrypts a sentence
Encryption
*/
public class Encryption extends java.swing.JFrame{
[code]....
View Replies
View Related
Feb 25, 2015
For this week's assignment, I am supposed to create a java program that encrypt's a user's sentence, outputs the encrypted message, then decrypts the message, outputting the user's original message.
This is what I have so far. It doesn't compile the last few lines since that is not correct Java syntax.
Java Code:
import java.util.Scanner;
import java.io.*;
public class Decrypter {
public static void main(String[] args) {
String sentence;
final char REAL_ALPHA[] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
[Code] .....
So you can see I have "realAlpha" which are regular letters of the alphabet, and "codeAlpha" which are the letters I want to encrypt with. I want 'a' equal to 'z,' 'b' equal to 'y', 'c' equal to 'x' and so forth in that sort of reverse order, you know? So the word "apple" would encrypt into "zkkov."
I am stuck as to how to replace the letters in this way. You can see I tried fumbling with sentence.replace to switch the letters out between the two arrays. Also, I only barely understand arrays.
View Replies
View Related
Aug 16, 2014
I am creating 2 different java codes for encryption and decryption separately based on RSA algorithm. The codes also involve swings for GUI. The problem with these codes are that my string is getting encrypted but after decrypting it,i do not get the string rather i get string of random numbers and alphabets. I am posting both the codes.
Encryption code:
import java.math.BigInteger;
import java.util.Random;
import java.io.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class cipher implements ActionListener
[Code] ....
Now the decryption code
import java.math.BigInteger;
import java.util.Random;
import java.io.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class decipher implements ActionListener
[Code] ....
The screenshots for respective codes are as attachments ....
View Replies
View Related
Apr 17, 2012
I'm currently working on a RSA Encryption using Fast Exponential technique. As the numbers I'm working with will be very huge, I am forced to use BigInteger.
As this is the first time I'm using Big Integer, I encountered quite a number of issues. I'll try my best to explain the errors I'm facing:
1. I had done this step: BigInteger d;
So I'm currently trying to get d = 0;
However, I keep getting an error required: BigInteger, found int.
When I changed it to d = new BigInteger(0) , I get this error:
java:19: error: constructor BigInteger in class BigInteger cannot be applied to given types;
d = new BigInteger(0);
^
required: no arguments
found: int
reason: actual and formal argument lists differ in length
Part of Code:
public class BigFastExponential
{
BigInteger e; // public exponenet: all has this
BigInteger d; // private key: only key owner has this
BigInteger n; // public modulus: all has this
/**
* Create a LongRSA object for a public key holder, with just e and n.
*/
public BigFastExponential(BigInteger public_e, BigInteger public_n)
[Code] ....
View Replies
View Related
Oct 1, 2014
I have following Cipher Code and test for it. But I am getting following exception.
Java Code:
java.lang.IllegalStateException: Cipher not initialized
at javax.crypto.Cipher.checkCipherState(Cipher.java:1672)
at javax.crypto.Cipher.doFinal(Cipher.java:2079)
at com.anjib.util.CipherUtil.encrypt(CipherUtil.java:67)
at com.anjib.util.CipherTest.testEncryptDecrypt(CipherTest.java:23) mh_sh_highlight_all('java'); Java Code: public class CipherUtil {
private static Logger log = Logger.getLogger(CipherUtil.class);
[Code] ....
View Replies
View Related
Oct 28, 2014
My assignment is to write a program that will encrypt and decrypt a sentence entered by a user but the encryption is to be random using an array. Can I convert my sentence(string) from char to int then create a random array to encrypt?
import java.util.Scanner;
import java.util.Random;
/*SentenceEncryptionProgram
*/
public class SentenceEncryption {
string sentence; //sentence entered by user
[Code] ....
View Replies
View Related
Jun 23, 2014
I am trying to put together an encryption/decryption application that will essentially accept a sentence that is submitted, and spit out the encrypted version and then switch it back to the correct sentence. I have been told to nest my information in the class (rather than the main), but am having difficulty actually understanding how to do this. The error that Eclipse is throwing me is also that it "could not find the main class." Here is my code:
import java.util.Arrays;
import java.util.Random;
public class encryptingWords {
public static void main(String[] args) {
final int ALPHASIZE = 26;
final char[] Lalpha =
[Code] .....
View Replies
View Related
Nov 4, 2014
I've written most of the code (along with another classmate) to get this to work, but I can't seem to return the encrypted value. I'm also trying to figure out how to separate the digits (or if I'm supposed to) to make the numbers encrypted. The main kicker is that we have to be using methods to return the final values. Everything compiles, (It compiles, but no results really.)
A company wants to transmit data over the telephone, but they are concerned that their phones may be tapped. All of their data is transmitted as four-digit integers. They have asked you to write a program that will encrypt their data so that it may be transmitted more securely. Your program should read a four-digit integer number and encrypt it as follows: Replace each digit by the remainder after (the sum of that digit plus 7) is divided by 10. Then, swap the first digit with the third, and swap the second digit with the fourth. Then print the encrypted integer. Do the encryption in a method and send the encrypted number back to main.
Here are the method headers: public static int encrypt(int num) // Takes num as a parameter and returns the encrypted value public static int getnum() // gets one number from the user Example: If the user enters 1234 they should see: 0189
import java.util.Scanner; //Needed for Scanner class
public class LNFI_LNFI_program2
{
public static void main(String[] args)
{
getnum(); //Calls for getnum() method
[Code] ....
View Replies
View Related
Jul 9, 2015
We currently have an application which uses JDBC to connect to the backend database (DB version - 11.2.0.3 ). The application uses a properties file in which the password for the db schema is hardcoded in plain text format. Due to security restrictions we have been asked to make sure the password is encrypted in the file and no direct access is made to the schema using the plain text password. Best options we can use to make this password encrypted both at Oracle DB side and Java side.
View Replies
View Related
Feb 26, 2015
try {
File configFile= new File("C: Documents and SettingsstudentMy DocumentsNetBeansProjectsCDASsrcconfig.xml ");
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(fXmlFile);
doc.getDocumentElement().normalize();
NodeList nList = doc.getElementsByTagName("config");
[Code] .....
This code is working properly but i have use path like this
File configFile= new File("srcconfig.xml");
Instead of system directory path i have to use path inside of project but i am getting an error-cannot find the specified file...
View Replies
View Related
Dec 1, 2014
In my web application i want to upload file to drop-box. I am getting file name from browser.Is it possible to upload file to drop-box with only file name.
Below the drop-box upload code with java.
File inputFile = new File("New Text Document.txt");
System.out.println("inputFile.getAbsoluteFile(): " + inputFile);
FileInputStream inputStream = new FileInputStream(inputFile);
try {
DbxEntry.File uploadedFile = client.uploadFile("/magnum-opus.txt",
DbxWriteMode.add(), inputFile.length(), inputStream);
System.out.println("Uploaded: " + uploadedFile.toString());
} finally {
inputStream.close();
}
In the above code the place New Text Document.txt we have to provide total path of file.
View Replies
View Related
Jan 18, 2014
I want to know can we put the data of html file example
<html>
<body><applet code="classname" width="100" height="100">
</applet>
</body>
</html>
into my Applet's java file it can be done i have read it somewhere and have also implemented it ..... but now unable to memorize it
View Replies
View Related
Jan 25, 2015
I have a java assignment concerning formatting. I know I have no syntax errors but that doesn't mean that my formatting is correct and I can't figure out how to create a .txt file and view my code in notepad just to verify the formatting.
public class Assignment1b {
public static void main (String[] args) {
String[] header = {"Wilson", "Office", "Supply", "Inventory", "Listing"};
String[] columnhead = {"Number", "Description", "Price", "Qty", "Net Price"};
String[] line1 = {"AB35", "Swingline Stapler", "19.95", "125", "2493.75"};
String[] line2 = {"CP05", "Canon Copier", "329.65", "175", "57,688.75"};
[Code] ....
View Replies
View Related
Jul 3, 2014
I need to use a some function which is already there in a jar file in another java.
for example,
Consider a jar file created from a java file in which only one constructor is there say SHA (String message).
I need to use this SHA method in another java file.
How to import the jar file to the existing java file? import .....
View Replies
View Related
Apr 9, 2015
I've written a java application with several classes all in the same .java file. It works just fine. Now, I've broken it up so that each class has its own .java file. Still works fine. My next step is to put those classes into a package, but I'm not about to get the program to run.The .java source files are all in /home/user/src
I've set the CLASSPATH to /home/user/src..All of the source files have "package com.myfirm.program" on the first line.I compiled the application with:
javac -d . File1.java File2.java File3.java (etc...)
the compiler created the directory: /home/user/src/com/myfirm/program and put all of the .class files in there.So how do I get the program to run? if I run from /home/usr/src
java File1
I get: Exception in thread "main" java.lang.NoClassDefFoundError: File1 (wrong name: com/myfirm/program/Program)
View Replies
View Related
Apr 14, 2015
I create 2 files:
CircleCalculationMethod.javaMain.java
In Main.java, How can i call method in CircleCalculationMethod.java ?
Should I put everything in same folder ??Should i do something like "import CircleCalculationMethod.java"Should i do something like create a package ...
I use Eclipse software
View Replies
View Related
Oct 7, 2014
How to split an XML file in java? what function and package should we use?
View Replies
View Related
May 25, 2015
Need to know how i can store a value in File which is in Properties?
Here I am placing my Properties code :
ReportHTML C:/bea/user_projects/domains/OICDomain/applications/IIMS/IIMS/target/source/REPORT_HTML_DUMP/
ReportEXCEL C:/bea/user_projects/domains/OICDomain/applications/IIMS/IIMS/target/source/REPORT_EXCEL_DUMP/
My Java File :
File destHtmlFolder = new File("C:/bea/user_projects/domains/OICDomain/DOC_SERVER/REPORT_HTML_DUMP");
File srcExcelFolder = new File("C:/bea/user_projects/domains/OICDomain/applications/IIMS/IIMS/target/source/REPORT_EXCEL_DUMP");
View Replies
View Related
May 30, 2014
In my project i need to use printer concepts to print a file but the output should be printed to another output file instead of printer,
View Replies
View Related
Jan 18, 2015
Is there a way to make a exe file, with all dependencies included so it is possible to run the application on any computers without installing any other programs?
View Replies
View Related
Mar 26, 2014
I am trying to .wav file using java eclipse ..
[B]import java.io.* ;
import sun.audio.*;
public class AudioDemo{
public static void main(String[] args)
throws Exception
[Code] ....
And I am getting the following errors ...
Exception in thread "main" java.io.FileNotFoundException: E:pppp.wma (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at AudioDemo.main(AudioDemo.java:10)
View Replies
View Related
Feb 7, 2014
I want to parse a java file (i.e., I need write some code which understand the content of a given java file--> the name of this java file will be entered as input). Then, after my code understand the content of the given java file, map this java file into another target language or platform. the output from my code is the new file which can run on the target language or platform.in the current state, I want to write some code which can understand a java file and can parse its content and display it on the console.
View Replies
View Related