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);
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 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 ....
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.
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 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'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 was giving a quick skim to some tutorials on the internet where I have found the exception that is handled is also declared in the throws clause of the method wrapping the try-catch block. For a code representation consider the following:
public void methodName() throws IOException { try { ... } catch (IOException ex) { .... TODO handle exception }
Right, so I got this program. It takes input from the user and assigns it to fields on an object. But, it's meant to check the users input. If the user enters bad input, it's supposed to throw this exception. For each of these exceptions, theres a class specifically for it.
public class PayrollDemo { public static void main(String[] args) { Payroll pr = new Payroll ("Test Name", 234); System.out.println("Current Employee Information. "); System.out.println("Name: " + pr.getName()); System.out.println("ID: " + pr.getID()); System.out.println("Hourly Pay Rate: " + pr.getHourlyPayRate());
[Code] ....
And this is the exception class.
public class InvalidNameException extends Exception { /** No-arg constructor */ public InvalidNameException() { super("Invalid name"); } }
PayrollDemo.java:43: error: cannot find symbol InvalidNameException.InvalidNameException(); ^ symbol: method InvalidNameException() location: class InvalidNameException 1 error
It's just meant to tell the user that they entered an invalid value, which would mean if they entered an empty string instead of a name.
I have a program which runs perfectly fine in Eclipse. however, the same program after exporting to jar in desktop and then executing in cmd gives exception.
why is this difference.
in eclipse. it is built up 1.6 JDK and run using 1.6 JRE.
in CMD, it runs by 1.7 JRE.
can this JRE version make a difference. Technically should not i believe.
value1 = text1.getText(); value2 = text2.getText(); Connect c = new Connect(value1,value2); if(c.check()== true) { Menu start = new Menu(c.getID()); dispose();
[code].....
I get an error "unreported exception java.SQLException; must be caught or declared to be thrown" how can i solve this I have taken a few basic classes but never got to exceptions.
So I've been working on this program to make tournament matches for beach volley.
First little info: (I'm Belgian so some words are Dutch) -Class Speler: has arraylist with information with which player already has been played (codesLijst) -Class Inschrijvingen: makes players sign up with their level and name -Class Wedstrijd: makes matches, checks with Inschrijvingen if the players already have played together. If so, gives message that they need to change partner. If not, makes them a team.
Now if I run the program with fresh players, none of them have had a partner, it works fine. If I make just one new team and the other already exists, it also works fine. It's when I make the two teams with existing records (to see whether they already played together), that the error comes.I know there's a lot of code duplicate, will clear out eventually, this is just a raw version.
CLASS SPELER
import java.util.ArrayList; public class Speler { private Wedstrijden wedstrijd; private Inschrijvingen inschrijving; private String naam, ploeg; private int setPunten, winPunten; private long time; private String code; private ArrayList<String> lijstCodes = new ArrayList<String>();
public static void main(String[] args) { float y = 7 * i; } }
It gives : Exception in thread "main" java.lang.NullPointerException : Line 5...Why is it giving NPE? Isnt the variable defaulted with 0.0f? Also, I am not performing any dot operation, it's just a multiplication operation.
i rewrote this code from head first java book . but every time i try to compile it it gives me this exception
java.lang.ExceptionInInitializerError Caused by: java.lang.RuntimeException: Uncompilable source code - simpleFrame is not abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener at simpleFrame.<clinit>(simpleFrame.java:6)
how can i instantiate simpleFrame class if i shoild make it abstract?
public class simpleFrame implements ActionListener{ JFrame f; public static void main(String[] args){ simpleFrame s = new simpleFrame();
I have studied that Generics are used to shift the Class Cast Exception into Compile time errors , So that we get errors at compile time error and we do correct them before executing ,but Here is a program in which i am getting Class Cast Exception
class Animal { } class Dog extends Animal { } class Cat extends Animal
[code]..
Getting Exception at line no 29 which i know why it occurs but just wanna ask that isn't it should be caught at compile time According to Generics ?
Is there any connection between packages and exception handling in java. Means is it necessary to create a package before trying exception handling examples?
Is there a special mechanism through which exception can be handled in a constructor?
Suppose while creation of an object there occurred an exception while creating an object, and the object is half constructed. How do we make sure we handle this kind of exceptions in a constructor?
I am trying send email .So I have downloaded javaEE and javamail jar files and added buildpath.And wrote this code below .But I am getting this exception.