How to resolve the algorithm Substitution cipher step by step in the PicoLisp programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Substitution cipher step by step in the PicoLisp 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 PicoLisp programming language

Source code in the picolisp programming language

(setq *A (chop "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"))
(setq *K (chop "VsciBjedgrzyHalvXZKtUPumGfIwJxqOCFRApnDhQWobLkESYMTN"))

(de cipher (Str D)
   (let (K *K  A *A)
      (and D (xchg 'A 'K))
      (pack
         (mapcar
            '((N)
               (or
                  (pick
                     '((A K) (and (= A N) K))
                     A
                     K )
                  N ) )
            (chop Str) ) ) ) )
(and
   (println 'encode (cipher "The quick brown fox jumped over the lazy dog's back"))
   (println 'decode (cipher @ T)) )

  

You may also check:How to resolve the algorithm Walk a directory/Non-recursively step by step in the C# programming language
You may also check:How to resolve the algorithm Fibonacci sequence step by step in the MAD programming language
You may also check:How to resolve the algorithm Fork step by step in the Mathematica/Wolfram Language programming language
You may also check:How to resolve the algorithm Color of a screen pixel step by step in the J programming language
You may also check:How to resolve the algorithm Active Directory/Connect step by step in the AutoIt programming language