Results 1 to 1 of 1
- 03-25-2009, 10:26 AM #1
Member
- Join Date
- Mar 2009
- Posts
- 27
- Rep Power
- 0
How to Encrypt content of txt file?
Hi,
I have write a java application to mix characters of the string, and save in the encrypted String.
Like that (first character in 8'th ...):
B1 B2 B3 B4 B5 B6 B7 B8 B9
B8 B1 B3 B4 B9 B2 B5 B7 B6
How to do the same thing for a text file?
(get 9 characters encrypt and write in other file)
Java Code:public class Det6enc { public static String mix(String str) { String enc = ""; char[] c = new char[9]; char[] b = new char[9]; int numro = ((str.length()-(str.length())%9)); for(int i=0; i<numro; i=i+9) { for(int j=0; j<9; j++) { b[j] = str.charAt(j+i); } c[0] = b[1]; c[1] = b[5]; c[2] = b[2]; c[3] = b[3]; c[4] = b[6]; c[5] = b[8]; c[6] = b[7]; c[7] = b[0]; c[8] = b[4]; for(int k=0; k<9; k++) { enc = enc + c[k]; } } for(int i=0; i<str.length()-numro; i++) { enc = enc + str.charAt((str.length()-(str.length())%9)+i); } return enc; } public static void main (String[] args) { String str = "ARTAN POTERA"; System.out.println (mix(str)); } }
Similar Threads
-
How can I save the content of textfield in a text file?
By fred in forum Java AppletsReplies: 7Last Post: 08-17-2010, 06:00 PM -
How to get the content of text file to write in JTextArea?
By realahmed8 in forum New To JavaReplies: 10Last Post: 05-24-2010, 08:25 PM -
I need code for Use of Iteam Field Content Master file.
By lavanya82 in forum Advanced JavaReplies: 0Last Post: 03-05-2009, 12:18 PM -
How to create new XML file using retreived XML content by using SAX API?
By jimranjava in forum XMLReplies: 0Last Post: 11-07-2008, 01:11 PM -
How to load binary content of a .class file
By boy22 in forum Advanced JavaReplies: 1Last Post: 08-03-2007, 06:21 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks