Page 1 of 1

Encryption & Decryption Program

Posted: 30 Oct 2011, 05:42
by Rajiv
Hi all!

Gonna be straight here: I need help coding a program in Java that can encrypt or decrypt a file. I am using ASCII values as my form of encryption. It is too late to change that. Is it possible to parse a file to String?

Thanking you!

Re: Encryption & Decryption Program

Posted: 30 Oct 2011, 08:12
by RuadRauFlessa
In what format do you currently have it?

Re: Encryption & Decryption Program

Posted: 30 Oct 2011, 08:16
by RuadRauFlessa
cuz you can always go and google and read over here.

http://download.oracle.com/javase/1.4.2 ... Guide.html

^^ allows you to encrypt directly from a file stream. Which is what I used to use. but it is quick and dirty.

Re: Encryption & Decryption Program

Posted: 30 Oct 2011, 13:32
by Bladerunner
Rajiv wrote: parse a file to String?
Byte array.

EDIT: Although the better method would be opening two file streams, and reading bits from the source stream, and encrypting it and writing it directly to the destination stream.

(As opposed to loading the whole thing into RAM ( :!: :!: :!: ), encrypting, and writing the whole thing to a stream again)

Re: Encryption & Decryption Program

Posted: 30 Oct 2011, 13:58
by RuadRauFlessa
Agree with Bladerunner I do... better to go through the file with a buffered stream than to read the whole file at once. What are you going to do if you get a file that is say... 300MB in size?

Re: Encryption & Decryption Program

Posted: 30 Oct 2011, 16:01
by Bladerunner
RuadRauFlessa wrote:Agree with Bladerunner I do... better to go through the file with a buffered stream than to read the whole file at once. What are you going to do if you get a file that is say... 300MB in size?
Nevermind 300MB, try 8GB+ :lol:

I wrote a file splitter once to split some game ISOs. :wink:

Re: Encryption & Decryption Program

Posted: 30 Oct 2011, 16:56
by RuadRauFlessa
Ooooh...
Yeah that can also be a problem.