Okay. I have encrypt and decrypt file done. Let start at being I ask user for key and what file what they want to read or encrypt. And encrypt. For decrypt it same code. Now i have problem at let say the user enter 5 for key. How can i write code that find the key and understand that file is not encrypt any more . Anyone? I try for if while dowhile
My_1 0 Light Poster
Recommended Answers
Jump to PostIf there are only 256 possible keys, just try each one in a loop until you get one that works.
Jump to PostYou will need to know something about the file so you can see if it decrypted correctly.
Many file types have a standard header ("magic number") at the start, eg pdf files start "%PDF", so you can look for that.
If you know it's an English text file then the …
Jump to PostI would structure it like (pseudo code)
for (int key = 0 to 255) { // try every key String decoded = decode(encoded, key) // decode encrypted data using key if (isValidText(decoded)) { write decoded to file break; } } ... boolean isValidText(String d) { for each …
Jump to PostJava chars are 16 bit UniCode, ans include Hebrew, Arabic, Chinese... all kinds of symbols.
Ordinary English text can be encoded in just 7 bits (values 0 - 127 or 7f) using the ASCII codes. Java UniCode is the same as ASCII for up to 127 (hex …
All 16 Replies
Taywin 312 Posting Virtuoso
My_1 0 Light Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
My_1 0 Light Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
My_1 0 Light Poster
My_1 0 Light Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
My_1 0 Light Poster
My_1 0 Light Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
My_1 0 Light Poster
My_1 0 Light Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
My_1 0 Light Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.