oezg / encryption-decryption-kt

0 stars 0 forks source link

Encryption - Decryption (Kotlin)

Description

A command line tool in Kotlin to help you encrypt/decrypt messages or files using a simple shifting algorithm.
The encryption is controlled by a key, a special parameter that controls the behavior of the encryption algorithm.

Encryption process in the Encryption-Decryption program

img.png

The key is assumed to mean that if a person knows the value of the key, they will be able to decrypt the text, and if they do not know it, they will not be able to decrypt the text. It's like a real key that can open up access to the message text.

Objectives

  1. Work with command-line arguments instead of the standard input.
  2. The ability to read and write the original and cipher data into files.
  3. When starting the program, the necessary algorithm should be specified by an argument.

Command line arguments:

The program parse these arguments from the command line:

The order of the arguments might be different. For example, -mode enc maybe at the end, at the beginning, or in the middle of the array.

Default values

Algorithms

Examples

Example 1

encryption with the unicode algorithm

Arguments:

-mode enc -key 5 -data "Welcome to hyperskill!" -alg unicode

Output:

\jqhtrj%yt%m~ujwxpnqq&

Example 2

decryption with the unicode algorithm

Arguments:

-key 5 -alg unicode -data "\jqhtrj%yt%m~ujwxpnqq&" -mode dec

Output:

Welcome to hyperskill!

Example 3

encryption with the shift algorithm

Arguments:

-key 5 -alg shift -data "Welcome to hyperskill!" -mode enc

Output:

Bjqhtrj yt mdujwxpnqq!

Example 4

decryption with the shift algorithm

Arguments:

-key 5 -alg shift -data "Bjqhtrj yt mdujwxpnqq!" -mode dec

Output:

Welcome to hyperskill!