How to resolve the algorithm Substitution cipher step by step in the jq programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Substitution cipher step by step in the jq programming language
Table of Contents
Problem Statement
Substitution Cipher Implementation - File Encryption/Decryption
Encrypt an input/source file by replacing every upper/lower case alphabets of the source file with another predetermined upper/lower case alphabets or symbols and save it into another output/encrypted file and then again convert that output/encrypted file into original/decrypted file. This type of Encryption/Decryption scheme is often called a Substitution Cipher.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Substitution cipher step by step in the jq programming language
Source code in the jq programming language
def key:
"]kYV}(!7P$n5_0i R:?jOWtF/=-pe'AD&@r6%ZXs\"v*N[#wSl9zq2^+g;LoB`aGh{3.HIu4fbK)mU8|dMET><,Qc\\C1yxJ";
def encode:
(key|explode) as $key
| explode as $exploded
| reduce range(0;length) as $i ([];
. + [$key[ $exploded[$i] - 32]] )
| implode;
def decode:
(key|explode) as $key
| explode as $exploded
| reduce range(0;length) as $i ([];
$exploded[$i] as $c
| . + [ $key | index($c) + 32] )
| implode ;
def task:
"The quick brown fox jumps over the lazy dog, who barks VERY loudly!"
| encode as $encoded
|"Encoded: \($encoded)",
"Decoded: \($encoded|decode)" ;
task
You may also check:How to resolve the algorithm Window creation step by step in the Processing programming language
You may also check:How to resolve the algorithm Real constants and functions step by step in the Scheme programming language
You may also check:How to resolve the algorithm Trabb Pardo–Knuth algorithm step by step in the Ruby programming language
You may also check:How to resolve the algorithm Evaluate binomial coefficients step by step in the Go programming language
You may also check:How to resolve the algorithm Numerical and alphabetical suffixes step by step in the Python programming language