kukumberman / csharp-cipher-cli

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

csharp-cipher-cli

Description

A command-line interface (CLI) tool that allows to encrypt/decrypt data with given key πŸ”

Try web version! 🌐

Usage

1st way

Use cmd to enter commands

See examples folder for more information

application.exe --action "action_value" --key "key_value" --file "C:/path/to/file.txt"
Parameter Value Description
--action encrypt | decrypt select what you want
--key enter yours please dont forget it
--file enter yours path to file (absolute or relative)

Encrypt

cipher-cli.exe --action encrypt --key foobar --file "./showcase.json"

Decrypt

cipher-cli.exe --action decrypt --key foobar --file "./showcase-encrypted.txt"

2nd way

This is kinda password manager tool

Requirements β€” data stored in special format

  • Run .exe file as regular application
  • File dialogue window will popup
  • Select file with encrypted contents
  • Enter key
  • Use arrow keys (↑, ↓) to navigate in list of entries
  • Press Enter key to select desired entry
  • It will show description of the entry and associated data (displayed as asterix as it might be sensitive information)
  • Again, use arrow keys to navigate, and select β€” it will copy that data to clipboard, so you can paste in the future

Special format

[
  {
    "name": "some website",
    "description": "email + password",
    "data": ["foobar@email.com", "123456"]
  },
  {
    "name": "another website",
    "description": "email + password",
    "data": ["user@foobar.com", "qwerty123"]
  }
]

How does it works

Step 1. Ask for text and key

Example

  • text β€” Hello, World!
  • key β€” 123

Step 2. Convert given text and key from normal string to array of bytes (in utf-8 encoding)

Example

  • text β€” [72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33]
  • key β€” [49, 50, 51]

Step 3. Sequentially xor each byte of text with byte of key (in the algorithm key becames normalized to match length)

Example

  • Normalized key: from [49, 50, 51] to [49, 50, 51, 49, 50, 51, 49, 50, 51, 49, 50, 51, 49]
  • Xoring: [72 ^ 49, 101 ^ 50, 108 ^ 51, 108 ^ 49, ...] β†’ [121, 87, 95, 93, ...]

Step 4. Put xored byte into new array at the corresponding index

Example

  • Output: [121, 87, 95, 93, 93, 31, 17, 101, 92, 67, 94, 87, 16]

Step 5. Convert array of bytes to string (in base64 encoding)

Example

  • Output: eVdfXV0fEWVcQ15XEA==

Step 6. Save output to disk or cloud, DON'T forget the key, otherwise you could not decrypt file 🀬

About


Languages

Language:C# 100.0%