Encryption / Decryption - How To Separate Digits To Make Numbers Encrypted
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
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 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've just written a program that generates 100 numbers that range from 0 ~ 25 using arrays, the program calls another method that sorts the even numbers into a separate array and returns the array. I need it to display both arrays, however, when I run my program, the numbers of both arrays are mixed together, and I'm not sure how to separate them.
[ public class Array1 { public static void main(String[] args) { int array [ ] = new int[100]; for (int i = 0; i < array.length; i++) { array[i] = (int) (Math.random() * 26);
I am writing a program that adds together large integers. I have to store each integer in an array of digits, with one digit per array element. Array length is 50 so integer is 50 digits long. I have to store numbers in right-shifting format with leading zeros. For example,
Sum.txt contains numbers to be added. There could be one or more numbers per line.each line must be read as string with next() since it's assumed to be a very long number. String of digits needs to be converted into an array of 50 digits. Method CharAt and Character.getNumericValue will be useful. All numbers in each line are to be added. There are no negative numbers and individual number might be 0 or answer might be 0. Answer is always 50 digits or fewer.
BigDecimal or BigInteger are not allowed.
I'm lost where it says to put number with leading zeros in a 50 room array. How do I add numbers after formatting numbers with leading zeros?
I am trying to create a method that reverses the digits of a number.
import java.util.*; public class KDowlingWeek7 { static Scanner console = new Scanner (System.in); //Scanner input = new Scanner(System.in); public static void main(String[] args) {
[Code] .....
The error I get is :
Error: cannot find symbol System.out.print(reverseDigit + " "); Symbol: variable reverseDigit Location: class KDowlingWeek7
The question is Write a program that displays all the numbers from 100 to 1000, ten per line, that are divisible by 5 and 6. and separated by exactly a space.
My assignment requirements are to display this in Dialog Box / message box . I have written this code so far
import javax.swing.JOptionPane; public class Exercise04_10 { public static void main(String[] args) { int count = 1; for (int i = 100; i <= 1000; i++) if (i % 5 == 0 && i % 6 == 0)
Goal is to: Write a program that prompts the user to input an integer and then outputs both the individual digits of the number and the sum of the digits.
First I don't know where I made mistakes here, and the only error it finds right now is that str2 was not initialized and I cannot figure out where/when to initialize it.
import javax.swing.JOptionPane; public class DigitsAndSum { public static void main (String[] args) { String str1; String str2; int int1 = 0; int int2 = 0;
I'm trying to play an encrypted HLS video using MediaView and MediaPlayer is throwing a "can't create player" exception. Searching for a solution all I found was this post from january last year, saying it is not supported and to add a feature request. I looked in the JDK bug system for HLS/live streaming and didn't saw anything related. Is this still not working on the latest JavaFX?
import java.util.Scanner; public class main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int number; System.out.println("Input a number");
[code]....
What i want to do is that if the number is greater than 50 to count until 100. else if the number is less than fifty to count for example from 36 to zero.
I am trying to make an encrypted video chat program using JMF. I have successfully written the "video chat" part - which includes getting data from webcam and transmitting it using RTP, but how to get raw data video to encrypt it before it stream between the webcam and the network.
For RTP I am using RTPManager, and for reading from the webcam I am using this code:
DataSource ds; CaptureDeviceInfo di = null; StateHelper sh = null;System.out.println("Started Video"); String str1 = "vfw:Logitech USB Video Camera:0"; String str2 = "vfw:Microsoft WDM Image Capture (Win32):0"; String str3 = "vfw:Microsoft WDM Image Capture (Win32):0 : vfw://0";
[Code] .....
I plan on using a stream cipher for encryption, maybe RC4.
I need to implement a URL which looks something like below one. The Notable thing is that its only one parameter i need to access and the value that's supposed to be held by the parameter is encrypted which may contains characters like & and =.
Example 1. www.abc.com/disp?v=qww78agd= The parameter v in above url contains value qww78agd=.
Supposing the encryption turns out the following way. Example 2. www.abc.com/disp?v=qww7&f=iuy68= www.abc.com/disp?v=qww7&f==iuy68=
Then servlet will take v and f as two separate parameters, whereas i want to obatain qww7&f==iuy68= from parameter.I thought of taking up all key value pairs from request HashMap and concatenating the joints via & and =. But the problem is that two consecutive = signs as in second case of example 2, its treated as only one equal to in request key,value map. Hence, my other = sign(s) are lost.Is there any way such that i can get query string part as it is on my servlet and parse it using string processing on my own?
So here is what i have so far for my sudoku game. Now my grid only displays textboxes where a user can input numbers but nothing will happen yet. I want to know how to make it so that the user can only input one character and only numbers. i would also like to know how to make some textboxes jdialogs displaying uneditable numbers that im taking from a sudoku website for the puzzle.
Main Class
import javax.swing.JOptionPane; public class Game{ public static void main(String[] args) { JOptionPane.showMessageDialog(null, "Hello. Welcome to a game of Sudoku by Ezra Zike."); Level select = new Level();
I have an program with an encryption and a decryption method, it works fine when i specify a name for the encrypted file, but i want the name for the encrypted file to be in cipher text, how do i do this and specify the path? i have marked out the "encryptionPath" specifically for specifying the location of the encrypted file which will have a cipher text name.
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);
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 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)