RSA Encryption Decryption Using Separate Codes With GUI
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 ....
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
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:
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 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{
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.
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 =
I want to encrypt and decrypt a txt file by using PGP.I completed my PGP Encryption.I'm getting an error in PGP Decryption. The error msg as follows
Quote:
Exception in thread "main" java.lang.IllegalArgumentException: Invalid PGP message at com.newpackage.bouncy.PGPUtils.getDataList(PGPUtil s.java:502) at com.newpackage.bouncy.PGPUtils.decryptFile(PGPUtil s.java:198) at com.newpackage.bouncy.PGPFileProcessor.decrypt(PGP FileProcessor.java:56) at com.newpackage.bouncy.Tester.testDecrypt(Tester.ja va:46) at com.newpackage.bouncy.Tester.main(Tester.java:61)
I am getting this error in the following line of my code.
PGPObjectFactory factory=new PGPObjectFactory(PGPUtil.getDecoderStream(is)); =>> Object obj=factory.nextObject();//here i am getting obj as null if (obj == null) { //System.out.println("Invalid PGP Message"); //System.exit(0);
In this code, I have to do a series of tasks to change a String using specialized codes that are inputted. The one that I am having trouble with is as follows:
MC-SLXD: Circulates the sub-string in position S with a length of L, rotate the string X characters over in the direction of D. All the arguments (S,L,X and D will be one character in length. The direction will be either L or R for Left or Right.Example: MC-332R/COMPUTER = COPUMTER.
I have to write the Insertion Sort Algorithm using Java codes and at the same time find the time of execution for different sizes of array, filled with random numbers. If I try to show the numbers inserted into the array randomly, they don't appear at the console.
import javax.swing.JOptionPane; public class Insertion { public static void main(String[]args){ int SizeArr = new Integer(JOptionPane.showInputDialog("Enter the size of teh array")).intValue(); int [] r= new int [SizeArr]; {for(int d=0; d<r.length; d++)
I have a request to create a java scheduled job to send email with attachment of word document every week. any example codes I can use. This is my first time to code this request, I do not what is the standard way to do it.
private void DecryptBActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: final String plainText; if (!areKeysPresent()) { // Method generates a pair of keys using the RSA algorithm and stores it // in their respective files generateKey();
[Code] ....
Everytime throwing exception "javax.crypto.IllegalBlockSizeException: Data must not be longer than 128 bytes" in decrypt method.
URL....So the problem is that when I type in "PA" it will display about 24 Zips and Populations before it stops. The problem is in the ZIPs file. It goes down the list and then takes the Zip from the Zips file to the Zips in the Population file and displays the Population. It will go to population 513 and stop. Reason being, there is no ZIP code in the Population file to display a population. The loop then stops. How can I get the program to skip over the zip code when there is no corresponding ZIP code in the other file and continue showing the other Pops..Here's what I currently have completed:
import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class Population { //Declaring global variables. Scanner fileScannerZip, fileScannerPop, inputFile; private String lineZip, linePop; int invalidZip;
I am getting error message on Java code that was developed by someone else and is supposed to work.
public String decrypt(String password) { try { // create the key and parameter spec KeySpec keySpec = new PBEKeySpec(password.toCharArray(), salt, interactions); SecretKey key = SecretKeyFactory.getInstance(keyFormat).generateSecret(keySpec); AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, interactions); // create the cipher
[code]...
the error message is as follows: Access restriction: The type 'BASE64Decoder" is not API (restriction on required library '/usr/lib64/jvm/java-1.8.0-openjdk-1.8.0/jre/lib/rd.jar')I am using eclipse.
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
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)
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)
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);
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
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.
in log4j,in a web aplication i need loging in separate file,logging for action package in one file and dao in another file in action package log a class if this is possible in a class then a level in a file another level in another file.
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.
We have this website that is run on two web applications. The first web application hosts the home page and clicking certain links in the home page would forward it to pages of the second web application where certain functionalities can be done. Now, there has been an initiative to redesign the site to have a login page and only logged in users could browse it. This would mean a login page being created in the first app, and when links to the second application are clicked, the pages are supposed to forward to it with the same session of the user that logged in.
We have already creating handling to pass the session from the first app to the second. Logging out from the first application would also invalidate the same user session in the second application. My questions is, is this a bad idea? would it be better to combine the two apps even if it would mean a huge impact?
or is there are better way to do this? like set it in web.xml. I have read that you cannot use two context for it.