CodeGym/Java Tasks/Encryption

Encryption

  • 10
  • Locked
Come up with an encryption/decryption mechanism. The program runs with one of the following sets of arguments: -e fileName fileOutputName -d fileName fileOutputName where: fileName is the name of a file to be encrypted/decrypted. fileOutputName is the name of the file where you need to write the re
You can't complete this task, because you're not signed in.
Comments (16)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
22 September 2025, 17:39
Anyone coming from other languages who's used to stuff like leetcode is likely going to feel a bit silly here. I went with a sequence of <character's ascii value encoded as a string>[<count encoded as a string>] prefaced with a single E in case something needed to be done for empty files too. Turns out something like the Caesar Cipher is more than enough for this problem.
Hoist
Level 7 , San Diego, United States
9 January 2024, 06:15
go with a simple encryption/decryption mechanism that uses the Caesar Cipher algorithm. The Caesar Cipher is a substitution cipher that replaces each letter in the plaintext with a letter a fixed number of positions down the alphabet. --- The mode variable specifies whether to encrypt or decrypt the data. --- The shift variable specifies the number of positions to shift the letters in the Caesar Cipher.
matemate123
Level 50 , Kraków, Poland
25 January 2023, 14:31
It's good that I remembered lesson from Java Syntax zero. You can look, on Java Syntax Zero Level 9, Lesson 6 Bitwise operations, part 2 -> 4.Encryption Rest is like always on this chapter ;)
Олег Байбула
Level 32 , Ukraine
Expert
20 February 2023, 13:52
Thank you, could not get it because, I'd skipped Bitwise lessons. 😁
Justin Smith
Level 41 , Greenfield, USA, United States
7 October 2021, 14:05
If you got to this task and panicked like I did "OMG they didn't teach us anything about encryption yet" relax It's not real encryption. It would help if they said "Don't use any of Java's encryption classes. Just convert each byte to another byte, and be able to do this process in reverse."
Jurij Thmsn
Level 29 , Flensburg, Germany
13 April 2021, 15:50
Make sure you take "-e" and "-d" as arguments, not "e" and "d" !
22 February 2021, 21:24
470
Isma Java Developer
30 December 2020, 09:28
To those who got confused by "encryption/decryption mechanism". You can create your own mechanism:
byte = byte + 1
is an encryption mechanism. The analogous decryption mechanism would be
byte = byte - 1
Nyerges Ferenc
Level 31 , Bükkábrány, Hungary
8 November 2020, 13:35
Cool task :-) Passed for 2nd ( I should have remembered the difference between i++ and ++i :-) )
Seferi
Level 22 , United Federation of Planets
18 October 2020, 19:36
This task was a lot of fun!
Agent Smith
Level 38
5 September 2020, 18:08
Wow, only 364 people managed to do this task by September 2020. Lowest I've seen so far! I'll leave a small hint: Caesar cipher It might look complicated to do at first, but in fact it is much easier to apply with files than with letters.
Sela
Level 20 , Poland
18 September 2020, 10:24
no of completions: 376 by now
Andrei
Level 41
28 January 2021, 08:55
455 today.
Youssef Amajout Talidni Future Java DEV
31 October 2023, 10:31
31 oct 2023 : 847 people