Specify Path Of Encrypted Filename In Cipher Text
May 8, 2015
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.
Here is my code so far
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
[Code] ......
View Replies
ADVERTISEMENT
Feb 26, 2015
I'm taking inheritance now and some things look confusing. I'm trying to do the following but the code, in particular, the constructor in subclasses are pointed to be wrong. The constructor in LongestWord is not correct,how to pass the filename into the constructor?
Java Code:
import java.util.Scanner;
import java.io.File;
public abstract class FileProcessor {
protected Scanner input;
public FileProcessor(String filename) throws Exception
[Code] ....
View Replies
View Related
May 15, 2014
I want to make a tool that does the 2 following things::
- Open files that are not .txt but can be opened as .txt and return them as a string. It just returns an empty string at the moment.
- The filenames are unknown, just the file extension at the end and the the YYYYMMDD number in front are always the same, therefore I'd like the app to simply scan every file in the same folder (not the same file twice, obviously). How can this be done?
That's what I've got so far.
Java Code:
public String readFile(String filename) throws FileNotFoundException {
Scanner scanner = null;
File file = new File(filename);
String output = "";
try{
[Code] .....
View Replies
View Related
May 6, 2014
I am facing a problem while executing a task. My task is to make such a code which will search for my source code file (abc.java) in all directories and then displays the code in textarea inside frame and along with that i also have to display the path of the file in text field. I have coded something but i am really not getting anywhere near my task.
import javax.swing.*;
import java.awt.*;
import java.io.*;
import java.util.*
public class Lab extends JFrame {
[Code] ....
View Replies
View Related
Jun 22, 2015
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?
View Replies
View Related
Nov 7, 2014
I am copying the xml files from one folder to other folder, in the source folder, i have some files which have some content like "backing File="$IDP_ ROOT/metadata/iPAU-SP-metadata.xml" but while writing to the destination folder.i am replacing the "$IDP_ROOT" with my current working directory. The entire copying of files is for deploying into tomcat server. The copying is done only when server starts for the first time.Problem: If i change the folder name from my root path in my machine after i run the server,the entire process will be stopped because the destination folder files already contains the content which is with existed files names or folder names.
So i want to change it to relative path instead absolute path. What is the best way to do it? Please look at code below:
[ // Getting the current working directory
String currentdir = new File(".").getAbsoluteFile().getParent() + File.separator;
if(currentdir.indexOf("ControlPanel")!=-1){
rootPath=currentdir.substring(0, currentdir.indexOf("ControlPanel"));
}else{
rootPath=currentdir;
[code]....
View Replies
View Related
Oct 23, 2014
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.
View Replies
View Related
Jan 24, 2015
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?
View Replies
View Related
Aug 4, 2014
I have an encrypted MSCONS.txt file as Outlook item. I also have a Digital Certificate file (Certificate.pfx) with a password.
How I can read the actual MSCONS.txt file in my java application? Any sample code snippet ...
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
Apr 12, 2014
We have been tasked to create a Vigenere Cipher. At this stage however, I am attempting to get the program to encrypt a phrase using a single letter key (Caesar cipher), before progressing to the final stage, implementing a functioning Vigenere Cipher. The code below is able to encrypt a word, capatalise it, remove white space and shift it a certain amount of places, given the provided letter. My problem is that because the single letter is a String, not a char, the phrase is being shifted incorrectly. For example, when the program is given the Inputs: This is a test with the single letter key A, the program shifts all the characters by 1. The output however should read THISISATEST as A is supposed to be 0.
import java.util.Scanner;
public class VigenereCipher {
public static void main(String[] args)
{
char c;
[code]....
View Replies
View Related
Jul 29, 2014
I am trying to encrypt a string using substitution cipher, the program doesnt show any errors but the output is not what is expected. On encryption it shows random characters whereas i want it to be encrypted by another letter. This is what I have done:
/* Encryption using substitution */
import java.io.*;
public class SSExp1 {
public static void main(String args[]) {
char[] ip= new char[20];
char[] op= new char[20];
char key = '3';
String b;
[Code] .....
View Replies
View Related
Jan 28, 2015
I'm building casar cipher with using ASCII. I'm done changing lower and upper case alphabet, but I don't know how to fix my code for changing number 9 to <.
here is my class code.
public class SimpleMessageCipher implements MessageCipher {
public String encode(String plainText,int shiftKey){
String cipherText="";
for(int i=0;i<plainText.length();i++)
{
//stores ascii value of character in the string at index 'i'
int c=plainText.charAt(i);
[Code]...
View Replies
View Related
Nov 1, 2014
I have been assigned to make a program that encodes and decodes a given message with the given key (spaced numbers, for example: 3 1 7 4 2 5). I'll post the code for all the classes that I am using below.
QueueInterface:
import java.util.*;
public interface QueueInterface<T>
{
T dequeue() throws QueueUnderflowException;
boolean isEmpty();
[Code] ....
Ok, so the classes to focus on are these:
CircularLinkedUnbndQueue
CircularLinkedQueueITD
Encoder
Decoder
EncodeDecodeConsole
EncodeDecodeITD
Because those are the ones I had to write myself, the others were given to us to use. As far as these classes go, they work fine without causing any errors from the input I give. For example if I enter a message and a key, it correctly encodes and decodes the message with the given key. What I'd like for you fine programmers to do is give feedback on those 6 classes. Like, suggestions on how to make them better or more efficient, neater, changing any of the methods to make them more efficient or prevent any errors beforehand, etc.
View Replies
View Related
Feb 8, 2015
I was tasked with creating a program that encrypts a line of text (for example, CANDY) by shifting the letters X amount of times. For example, if the user inputs the sentence CANDY and selects a shift of 5, the output would be: HFSID. I got this part working fine. The issue I am having is with the decryption part of the program.
This is simply the reverse of the above, as the user would enter the phrase HFSID, with a shift of 5, and the program would output: CANDY. It works fine, all except for one letter, being the "F" letter. With my code, when I enter the above word to be decrypted it outputs: C[NDY
Obviously, that [ bracket is not an 'A'. I realise the issue falls with the equation, Here is my code:
public class SimpleEncryption {
/**
* @param args the command line arguments
*/
static int answer;
public static void main(String[] args) {
String cipher = JOptionPane.showInputDialog(null, "Please enter a sentence or word that you wish to encode or decode. This program uses"
+ " a basic cipher shift.");
[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
Jun 30, 2014
I want to encrypt a file and decrypt it on another host. For decryption on another host I guess I need to transfer the cipher... how can this be done? How can you write a Cipher to disk?Or am I completely on a wron track?
The following code is doing it already on one host:
package test;
import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.ObjectInputStream;import java.io.ObjectOutputStream;import java.io.Serializable;import java.security.Provider;
import javax.crypto.*;import javax.crypto.spec.DESKeySpec;
[Code] ....
View Replies
View Related
Jan 21, 2014
I'm trying to make a simple Caesar cipher that takes in a String as the first argument and a integer shift as the second argument. Namely, there appears to be a problem with the loop and how I have declared the array - I want the converted characters to be put into a new array called newCharacterArray, converted back to a String and displayed in the command prompt window.
public class Caesar {
public static void main(String inString, int k) {
System.out.println("String: " + inString);
char inStringArray[] = inString.toCharArray();
[code]....
View Replies
View Related
May 13, 2015
This is the code that I wrote but I have two problem with two buttons one of them ... I want to delete the selected text inside the text Area which represented as b[8] and the other button that I want to select parts of the texts which represented as b[0]....
Here is the code..
package KOSAR2;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
[Code] .....
View Replies
View Related
Dec 12, 2014
I am checking how to do following task.
01. pickup the selected text file and read the line by line and output the text in to visual text pane.
what i did:.
01. I wrote code that read the text file and output in to jave console/ also some of the interface.
the code read txt file:
Java Code:
String fileName = "C:/Users/lakshan/Desktop/lawyer.txt";
File textFile = new File(fileName);
Scanner in = new Scanner (textFile);
while(in.hasNextLine()){
[code]....
so it will read any text file dynamically and output to the text pane in interface. I think scanner code must be execute after the select the file from the browser and set the scanned result in to variable. then later out put the var as string in some jswing component?
View Replies
View Related
May 5, 2014
My OS: Windows 7
Problem:
I've tried where javac in command prompt but it can't locate it. I need to know how to set JDK 8 as PATH.
View Replies
View Related
May 12, 2014
What I do wrong when I trying to set path to file in my jar app. I have application which work with xml file. I have next project structure:
/project_root_directory
|_ /lib
|_ /resources/file.xml
|_ /src
So, I need to set correctly path to my jar file, because when I running it from IDE, it works nice. By default it seems:
private File file;
private StreamResult streamResult;
file = new File("resources/file.xml");
streamResult = new StreamResult(file);
And methods where I can modify the DOM structure via transformer in end of methods:
transformer.transform(source, streamResult);
So, I trying set path to file:
private URL url;
...
file = new File(url.getPath());
streamResult = new StreamResult(file);
But it didn't not work, because when I trying to get resource by next condition
url = getClass().getResource("resources/file.xml");
url = getClass().getResource("resources/file.xml");url = getClass().getResource(url = getClass().getResource("resources/file.xml");resources/file.xml");
url - is null
Okay..
I tried next solution
InputStream input = getClass().getResourceAsStream("resources/file.xml");
There, I got also null....
Also, I tried made absolute path
filePath = file.getAbsolutePath();
file = new File(filePath);
streamResult = new StreamResult(file);
But it also didn't work. There I got message seems like: "Can't find resource /User/user1/Desktop/program1/resources/file.xml" - but that's really absolute path to a file.
Also, I tried made it via System.getProperty
String filename = "file.xml";
String workingDir = System.getProperty("user.dir");
finalfile = workingDir + File.separator + "resources" + File.separator + filename;
file = new File(finalfile);
I also made unit test which completed with "green light", but in jar its wrong with message "Can't find resource /User/user1/Desktop/program1/resources/file.xm" ....
View Replies
View Related
Sep 11, 2014
relative path not working if specified folder is outside eclipse IDE, but if i put same folder in current project it is working.
View Replies
View Related
Feb 25, 2015
I have the Java Development Kit downloaded in my C file and my book tells me to compile the program I need to open command windowand change the directory where the program is stored. I tried the command cd to change directory and received this message "The system cannot find the path specified."
I checked the Environment Variables on Windows 7 and the Path says: C:Program Files (x86)Javajre1.8.0_31in
This is after many tries and i still can't change directory and i keep getting the same message.
View Replies
View Related
Mar 2, 2014
I have BlueJ installed on my computer and it does the job of compiling the java source code written in it. If I want to write and compile source code outside of BlueJ do I still need to download the Java SDK and set the PATH variable, even though I am apparently able to do it in BlueJ?
View Replies
View Related
Feb 5, 2014
I have a data.json in my J2EE web app.I need to load it either from local path when unit testing or from url when the server starts up.
so I've set it to get the local path by default and what I'm trying to do is that it is is running on a server, I'd like to change the path to a url.
Here is my code:
public String getUrlBase(HttpServletRequest request) {
URL requestUrl;
try {
requestUrl = new URL(request.getRequestURL().toString());
String portString = requestUrl.getPort() == -1 ? "" : ":" + requestUrl.getPort();
return requestUrl.getProtocol() + "://" + requestUrl.getHost() + portString + request.getContextPath() + "/";
} catch (MalformedURLException e) {
e.printStackTrace();
}
return null;
}
which works fine. The only issue is that I had to place this in the login page. Is there a way I can only set the path to the base url upon server start up?
View Replies
View Related