Encryption & Decryption Program

All topics about coding, designing, etc. goes in here.
Post Reply
Rajiv
Registered User
Posts: 2178
Joined: 03 Dec 2010, 20:26

Encryption & Decryption Program

Post 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!
"Because I don't say it...don't mean I ain't thinking it!"
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: Encryption & Decryption Program

Post by RuadRauFlessa »

In what format do you currently have it?
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: Encryption & Decryption Program

Post 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.
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
Bladerunner
Registered User
Posts: 14338
Joined: 04 Sep 2004, 02:00
Processor: i386DX Sooper
Motherboard: A blue one
Graphics card: A red one
Memory: Hard drive
Location: On a Möbius strip
Contact:

Re: Encryption & Decryption Program

Post 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)
If I weren't insane: I couldn't be so brilliant! - The Joker
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: Encryption & Decryption Program

Post 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?
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
Bladerunner
Registered User
Posts: 14338
Joined: 04 Sep 2004, 02:00
Processor: i386DX Sooper
Motherboard: A blue one
Graphics card: A red one
Memory: Hard drive
Location: On a Möbius strip
Contact:

Re: Encryption & Decryption Program

Post 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:
If I weren't insane: I couldn't be so brilliant! - The Joker
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: Encryption & Decryption Program

Post by RuadRauFlessa »

Ooooh...
Yeah that can also be a problem.
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
Post Reply