How to resolve the algorithm Vigenère cipher step by step in the J programming language

Published on 12 May 2024 09:40 PM
#J

How to resolve the algorithm Vigenère cipher step by step in the J programming language

Table of Contents

Problem Statement

Implement a   Vigenère cypher,   both encryption and decryption. The program should handle keys and text of unequal length, and should capitalize everything and discard non-alphabetic characters. (If your program handles non-alphabetic characters in another way, make a note of it.)

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Vigenère cipher step by step in the J programming language

Source code in the j programming language

ALPHA=: (65,:26) ];.0 a.               NB. Character Set
preprocess=: (#~ e.&ALPHA)@toupper     NB. force uppercase and discard non-alpha chars
vigEncryptRC=: 0 vig ALPHA preprocess
vigDecryptRC=: 1 vig ALPHA preprocess


   'VIGENERECIPHER' vigEncryptRC 'Beware the Jabberwock, my son! The jaws that bite, the claws that catch!'
WMCEEIKLGRPIFVMEUGXQPWQVIOIAVEYXUEKFKBTALVXTGAFXYEVKPAGY
   'VIGENERECIPHER' vigDecryptRC 'WMCEEIKLGRPIFVMEUGXQPWQVIOIAVEYXUEKFKBTALVXTGAFXYEVKPAGY'
BEWARETHEJABBERWOCKMYSONTHEJAWSTHATBITETHECLAWSTHATCATCH


  

You may also check:How to resolve the algorithm Maze solving step by step in the Racket programming language
You may also check:How to resolve the algorithm Arrays step by step in the MiniScript programming language
You may also check:How to resolve the algorithm Babbage problem step by step in the Liberty BASIC programming language
You may also check:How to resolve the algorithm Address of a variable step by step in the REXX programming language
You may also check:How to resolve the algorithm Add a variable to a class instance at runtime step by step in the Slate programming language