Sponsors: Michael Fertik - Best JAVA Web hosting Company & 30% off


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-29-2009, 02:03 AM
Member
 
Join Date: Nov 2009
Posts: 3
Rep Power: 0
Rock-On is on a distinguished road
Default Readin from a file. and storing the information. (read inside)
Code:
	public void encryptFile(String fileName) {
		try { 
			String inputFile = fileName+".java";
			File file = new File(inputFile); 
			int fileLength = (int)file.length(); 
			byte fileBytes[] = new byte[fileLength]; 
			
			DataInputStream dos = new DataInputStream(new BufferedInputStream(new FileInputStream(inputFile))); 
			dos.readFully(fileBytes, 0, fileLength); 
			dos.close();
			
			File Name = new File(inputFile);
			Name.delete();

			for(int currentByte = 0; currentByte < fileBytes.length; currentByte++)
				fileBytes[currentByte] = (byte)(~fileBytes[currentByte]);
				
			FileOutputStream encryptedFile = new FileOutputStream(fileName+".txt");
			encryptedFile.write(fileBytes);
			encryptedFile.close();
		} catch(Exception ex) { ex.printStackTrace(); }
	}
Hello. I am using the above code (^^) to encrypt my .java files to .txt files and delete the .java ones, so they go from example:

Code:
import javax.swing.JFrame;

public class File1 {
	static JFrame frame = new JFrame();
}
too

Code:
–’‹•ž‰ž‡Œˆ–‘˜ѵž’šŠ“–œœ“žŒŒ߹–“š„Œ‹ž‹–œߵž’š™ž’š‘šˆߵž’š‚
(i actually encrypted it.)

now i ned to be able to read from this by doing something like

(this wont work)
Code:
[add unencryptin code here.]
File Frame = new File(File1);
so i can now do.

Code:
Frame.frame.setVisible(true);
and thus letting me read my files with out storing it in .java so my code cannot be leeched or something.

thank-you for your help.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 11-29-2009, 08:59 AM
Senior Member
 
Join Date: Sep 2008
Location: Voorschoten, the Netherlands
Posts: 3,364
Rep Power: 5
JosAH is on a distinguished road
Default
Your encryption code is a (very weak) two way encryption because all you do is flip every bit in the data. Apply the same code again to the encrypted data and voila, you'll have your original data back.

kind regards,

Jos
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 11-29-2009, 10:26 AM
Senior Member
 
Join Date: Nov 2009
Posts: 139
Rep Power: 0
dinosoep is on a distinguished road
Default
why would you encrypt java files?
normally you only distrebute a class file whitch is already encrypted?
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
storing information bsebal28 New To Java 3 03-26-2009 08:10 AM
Problem with storing an image into file??? pavankumar.thati JavaServer Pages (JSP) and JSTL 0 02-22-2009 04:35 PM
Storing the data in a file vasavi.singh New To Java 4 02-20-2009 04:01 PM
Help in storing Information care New To Java 1 12-01-2008 09:16 PM
storing and retrieving a file as such anil_manu Advanced Java 0 03-11-2008 01:27 PM


Java Forums is supported by the best jsp hosting.

All times are GMT +2. The time now is 08:33 AM.



VBulletin, Copyright 2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright 2006 - 2007, www.java-forums.org