WeixiangYan/CodeTransOcean huggingface dataset:
Task: Caesar cipher








VB: Option Explicit

Sub Main_Caesar()
Dim ch As String
    ch = Caesar_Cipher("CAESAR: Who is it in the press that calls on me? I hear a tongue, shriller than all the music, Cry 
    Debug.Print ch
    Debug.Print Caesar_Cipher(ch, -14)
End Sub

Function Caesar_Cipher(sText As String, lngNumber As Long) As String
Dim Tbl, strGlob As String, strTemp As String, i As Long, bytAscii As Byte
  Const MAJ As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    Const NB_LETTERS As Byte = 26
      Const DIFFASCIIMAJ As Byte = 65 - NB_LETTERS
        Const DIFFASCIIMIN As Byte = 97 - NB_LETTERS
    
    strTemp = sText
    If lngNumber < NB_LETTERS And lngNumber > NB_LETTERS * -1 Then
        strGlob = String(NB_LETTERS * 4, " ")
        LSet strGlob = MAJ & MAJ & MAJ
        Tbl = Split(StrConv(strGlob, vbUnicode), Chr(0))
        For i = 1 To Len(strTemp)
            If Mid(strTemp, i, 1) Like "[a-zA-Z]" Then
                bytAscii = Asc(Mid(strTemp, i, 1))
                If Mid(strTemp, i, 1) = Tbl(bytAscii - DIFFASCIIMAJ) Then
                    Mid(strTemp, i) = Tbl(bytAscii - DIFFASCIIMAJ + lngNumber)
                Else
                    Mid(strTemp, i) = LCase(Tbl(bytAscii - DIFFASCIIMIN + lngNumber))
                End If
            End If
        Next i
    End If
    Caesar_Cipher = strTemp
End Function



Fortran: program Caesar_Cipher
  implicit none

  integer, parameter :: key = 3     
  character(43) :: message = "The five boxing wizards jump quickly"

  write(*, "(2a)") "Original message  = ", message
  call encrypt(message)
  write(*, "(2a)") "Encrypted message = ", message
  call decrypt(message)
  write(*, "(2a)") "Decrypted message = ", message
  
contains

subroutine encrypt(text)
  character(*), intent(inout) :: text
  integer :: i
  
  do i = 1, len(text)
    select case(text(i:i))
      case ('A':'Z')
        text(i:i) = achar(modulo(iachar(text(i:i)) - 65 + key, 26) + 65)
      case ('a':'z')
        text(i:i) = achar(modulo(iachar(text(i:i)) - 97 + key, 26) + 97)
    end select
  end do
end subroutine

subroutine decrypt(text)
  character(*), intent(inout) :: text
  integer :: i
  
  do i = 1, len(text)
    select case(text(i:i))
      case ('A':'Z')
        text(i:i) = achar(modulo(iachar(text(i:i)) - 65 - key, 26) + 65)
      case ('a':'z')
        text(i:i) = achar(modulo(iachar(text(i:i)) - 97 - key, 26) + 97)
    end select
  end do
end subroutine

end program Caesar_Cipher
Task: Caesar cipher






PHP: <?php
function caesarEncode( $message, $key ){
    $plaintext = strtolower( $message );
    $ciphertext = "";
    $ascii_a = ord( 'a' );
    $ascii_z = ord( 'z' );
    while( strlen( $plaintext ) ){
        $char = ord( $plaintext );
        if( $char >= $ascii_a && $char <= $ascii_z ){
            $char = ( ( $key + $char - $ascii_a ) % 26 ) + $ascii_a;
        }
        $plaintext = substr( $plaintext, 1 );
        $ciphertext .= chr( $char );
    }
    return $ciphertext;
}

echo caesarEncode( "The quick brown fox Jumped over the lazy Dog", 12 ), "\n";
?>





Fortran: program Caesar_Cipher
  implicit none

  integer, parameter :: key = 3     
  character(43) :: message = "The five boxing wizards jump quickly"

  write(*, "(2a)") "Original message  = ", message
  call encrypt(message)
  write(*, "(2a)") "Encrypted message = ", message
  call decrypt(message)
  write(*, "(2a)") "Decrypted message = ", message
  
contains

subroutine encrypt(text)
  character(*), intent(inout) :: text
  integer :: i
  
  do i = 1, len(text)
    select case(text(i:i))
      case ('A':'Z')
        text(i:i) = achar(modulo(iachar(text(i:i)) - 65 + key, 26) + 65)
      case ('a':'z')
        text(i:i) = achar(modulo(iachar(text(i:i)) - 97 + key, 26) + 97)
    end select
  end do
end subroutine

subroutine decrypt(text)
  character(*), intent(inout) :: text
  integer :: i
  
  do i = 1, len(text)
    select case(text(i:i))
      case ('A':'Z')
        text(i:i) = achar(modulo(iachar(text(i:i)) - 65 - key, 26) + 65)
      case ('a':'z')
        text(i:i) = achar(modulo(iachar(text(i:i)) - 97 - key, 26) + 97)
    end select
  end do
end subroutine

end program Caesar_Cipher
Task: Caesar cipher

C: #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#define caesar(x) rot(13, x)
#define decaesar(x) rot(13, x)
#define decrypt_rot(x, y) rot((26-x), y)

void rot(int c, char *str)
{
	int l = strlen(str);
        
        const char*  alpha_low  = "abcdefghijklmnopqrstuvwxyz"; 

        const char*  alpha_high = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
   
       
       char subst;  
       int idx;    

         int i; 

	for (i = 0; i < l; i++)  
	{
		if( 0 == isalpha(str[i]) )  continue; 

                idx = (int) (tolower(str[i]) - 'a') + c) % 26; 

		if( isupper(str[i]) )
                    subst = alpha_high[idx]; 
                else
                    subst = alpha_low[idx]; 

               str[i] = subst;

	}
}


int main(int argc, char** argv)
{
	char str[] = "This is a top secret text message!";
	
	printf("Original: %s\n", str);
	caesar(str);
	printf("Encrypted: %s\n", str);
	decaesar(str);
	printf("Decrypted: %s\n", str);
	
	return 0;
}









COBOL:        identification division.
       program-id. caesar.
       data division.
       1 msg pic x(50)
           value "The quick brown fox jumped over the lazy dog.".
       1 offset binary pic 9(4) value 7.
       1 from-chars pic x(52).
       1 to-chars pic x(52).
       1 tabl.
        2 pic x(26) value "abcdefghijklmnopqrstuvwxyz".
        2 pic x(26) value "ABCDEFGHIJKLMNOPQRSTUVWXYZ".
        2 pic x(26) value "abcdefghijklmnopqrstuvwxyz".
        2 pic x(26) value "ABCDEFGHIJKLMNOPQRSTUVWXYZ".
       procedure division.
       begin.
           display msg
           perform encrypt
           display msg
           perform decrypt
           display msg
           stop run
           .

       encrypt.
           move tabl (1:52) to from-chars
           move tabl (1 + offset:52) to to-chars
           inspect msg converting from-chars
               to to-chars
           .

       decrypt.
           move tabl (1 + offset:52) to from-chars
           move tabl (1:52) to to-chars
           inspect msg converting from-chars
               to to-chars
           .
       end program caesar.
Task: Caesar cipher



C#: using System;
using System.Linq;

namespace CaesarCypher
{
    class Program
    {
        static char Encrypt(char ch, int code)
        {
            if (!char.IsLetter(ch)) return ch;

            char offset = char.IsUpper(ch) ? 'A' : 'a';
            return (char)((ch + code - offset) % 26 + offset);
        }

        static string Encrypt(string input, int code)
        {
            return new string(input.Select(ch => Encrypt(ch, code)).ToArray());
        }

        static string Decrypt(string input, int code)
        {
            return Encrypt(input, 26 - code);
        }

        const string TestCase = "Pack my box with five dozen liquor jugs.";

        static void Main()
        {
            string str = TestCase;

            Console.WriteLine(str);
            str = Encrypt(str, 5);
            Console.WriteLine("Encrypted: " + str);
            str = Decrypt(str, 5);
            Console.WriteLine("Decrypted: " + str);
            Console.ReadKey();
        }
    }
}







COBOL:        identification division.
       program-id. caesar.
       data division.
       1 msg pic x(50)
           value "The quick brown fox jumped over the lazy dog.".
       1 offset binary pic 9(4) value 7.
       1 from-chars pic x(52).
       1 to-chars pic x(52).
       1 tabl.
        2 pic x(26) value "abcdefghijklmnopqrstuvwxyz".
        2 pic x(26) value "ABCDEFGHIJKLMNOPQRSTUVWXYZ".
        2 pic x(26) value "abcdefghijklmnopqrstuvwxyz".
        2 pic x(26) value "ABCDEFGHIJKLMNOPQRSTUVWXYZ".
       procedure division.
       begin.
           display msg
           perform encrypt
           display msg
           perform decrypt
           display msg
           stop run
           .

       encrypt.
           move tabl (1:52) to from-chars
           move tabl (1 + offset:52) to to-chars
           inspect msg converting from-chars
               to to-chars
           .

       decrypt.
           move tabl (1 + offset:52) to from-chars
           move tabl (1:52) to to-chars
           inspect msg converting from-chars
               to to-chars
           .
       end program caesar.
Task: Caesar cipher


C++: #include <string>
#include <iostream>
#include <algorithm>
#include <cctype>

class MyTransform {
private : 
   int shift ;
public :
   MyTransform( int s ) : shift( s ) { } 

  char operator( )( char c ) {
      if ( isspace( c ) ) 
	 return ' ' ;
      else {
	 static std::string letters( "abcdefghijklmnopqrstuvwxyz" ) ;
	 std::string::size_type found = letters.find(tolower( c )) ;
	 int shiftedpos = ( static_cast<int>( found ) + shift ) % 26 ;
	 if ( shiftedpos < 0 ) 
	    shiftedpos = 26 + shiftedpos ;
	 char shifted = letters[shiftedpos] ;
	 return shifted ;
      }
  }
} ;

int main( ) {
   std::string input ;
   std::cout << "Which text is to be encrypted ?\n" ;
   getline( std::cin , input ) ;
   std::cout << "shift ?\n" ;
   int myshift = 0 ;
   std::cin >> myshift ;
   std::cout << "Before encryption:\n" << input << std::endl ;
   std::transform ( input.begin( ) , input.end( ) , input.begin( ) ,
	 MyTransform( myshift ) ) ;
   std::cout << "encrypted:\n" ;
   std::cout << input << std::endl ;
   myshift *= -1 ; 
   std::transform ( input.begin( ) , input.end( ) , input.begin( ) ,
	 MyTransform( myshift ) ) ;
   std::cout << "Decrypted again:\n" ;
   std::cout << input << std::endl ;
   return 0 ;
}








COBOL:        identification division.
       program-id. caesar.
       data division.
       1 msg pic x(50)
           value "The quick brown fox jumped over the lazy dog.".
       1 offset binary pic 9(4) value 7.
       1 from-chars pic x(52).
       1 to-chars pic x(52).
       1 tabl.
        2 pic x(26) value "abcdefghijklmnopqrstuvwxyz".
        2 pic x(26) value "ABCDEFGHIJKLMNOPQRSTUVWXYZ".
        2 pic x(26) value "abcdefghijklmnopqrstuvwxyz".
        2 pic x(26) value "ABCDEFGHIJKLMNOPQRSTUVWXYZ".
       procedure division.
       begin.
           display msg
           perform encrypt
           display msg
           perform decrypt
           display msg
           stop run
           .

       encrypt.
           move tabl (1:52) to from-chars
           move tabl (1 + offset:52) to to-chars
           inspect msg converting from-chars
               to to-chars
           .

       decrypt.
           move tabl (1 + offset:52) to from-chars
           move tabl (1:52) to to-chars
           inspect msg converting from-chars
               to to-chars
           .
       end program caesar.
Task: Caesar cipher





Java: public class Cipher {
    public static void main(String[] args) {

        String str = "The quick brown fox Jumped over the lazy Dog";

        System.out.println( Cipher.encode( str, 12 ));
        System.out.println( Cipher.decode( Cipher.encode( str, 12), 12 ));
    }

    public static String decode(String enc, int offset) {
        return encode(enc, 26-offset);
    }

    public static String encode(String enc, int offset) {
        offset = offset % 26 + 26;
        StringBuilder encoded = new StringBuilder();
        for (char i : enc.toCharArray()) {
            if (Character.isLetter(i)) {
                if (Character.isUpperCase(i)) {
                    encoded.append((char) ('A' + (i - 'A' + offset) % 26 ));
                } else {
                    encoded.append((char) ('a' + (i - 'a' + offset) % 26 ));
                }
            } else {
                encoded.append(i);
            }
        }
        return encoded.toString();
    }
}





COBOL:        identification division.
       program-id. caesar.
       data division.
       1 msg pic x(50)
           value "The quick brown fox jumped over the lazy dog.".
       1 offset binary pic 9(4) value 7.
       1 from-chars pic x(52).
       1 to-chars pic x(52).
       1 tabl.
        2 pic x(26) value "abcdefghijklmnopqrstuvwxyz".
        2 pic x(26) value "ABCDEFGHIJKLMNOPQRSTUVWXYZ".
        2 pic x(26) value "abcdefghijklmnopqrstuvwxyz".
        2 pic x(26) value "ABCDEFGHIJKLMNOPQRSTUVWXYZ".
       procedure division.
       begin.
           display msg
           perform encrypt
           display msg
           perform decrypt
           display msg
           stop run
           .

       encrypt.
           move tabl (1:52) to from-chars
           move tabl (1 + offset:52) to to-chars
           inspect msg converting from-chars
               to to-chars
           .

       decrypt.
           move tabl (1 + offset:52) to from-chars
           move tabl (1:52) to to-chars
           inspect msg converting from-chars
               to to-chars
           .
       end program caesar.
Task: Caesar cipher







Python: fun caesar(s, k, decode: false):
    if decode:
        k = 26 - k
    result = ''
    for i in s.uppercase() where 65 <= ord(i) <= 90:
        result.push! char(ord(i) - 65 + k) mod 26 + 65
    return result

let message = "The quick brown fox jumped over the lazy dogs"
let encrypted = caesar(msg, 11)
let decrypted = caesar(enc, 11, decode: true)

print(message, encrypted, decrypted, sep: '\n')



COBOL:        identification division.
       program-id. caesar.
       data division.
       1 msg pic x(50)
           value "The quick brown fox jumped over the lazy dog.".
       1 offset binary pic 9(4) value 7.
       1 from-chars pic x(52).
       1 to-chars pic x(52).
       1 tabl.
        2 pic x(26) value "abcdefghijklmnopqrstuvwxyz".
        2 pic x(26) value "ABCDEFGHIJKLMNOPQRSTUVWXYZ".
        2 pic x(26) value "abcdefghijklmnopqrstuvwxyz".
        2 pic x(26) value "ABCDEFGHIJKLMNOPQRSTUVWXYZ".
       procedure division.
       begin.
           display msg
           perform encrypt
           display msg
           perform decrypt
           display msg
           stop run
           .

       encrypt.
           move tabl (1:52) to from-chars
           move tabl (1 + offset:52) to to-chars
           inspect msg converting from-chars
               to to-chars
           .

       decrypt.
           move tabl (1 + offset:52) to from-chars
           move tabl (1:52) to to-chars
           inspect msg converting from-chars
               to to-chars
           .
       end program caesar.
Task: Caesar cipher








VB: Option Explicit

Sub Main_Caesar()
Dim ch As String
    ch = Caesar_Cipher("CAESAR: Who is it in the press that calls on me? I hear a tongue, shriller than all the music, Cry 
    Debug.Print ch
    Debug.Print Caesar_Cipher(ch, -14)
End Sub

Function Caesar_Cipher(sText As String, lngNumber As Long) As String
Dim Tbl, strGlob As String, strTemp As String, i As Long, bytAscii As Byte
  Const MAJ As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    Const NB_LETTERS As Byte = 26
      Const DIFFASCIIMAJ As Byte = 65 - NB_LETTERS
        Const DIFFASCIIMIN As Byte = 97 - NB_LETTERS
    
    strTemp = sText
    If lngNumber < NB_LETTERS And lngNumber > NB_LETTERS * -1 Then
        strGlob = String(NB_LETTERS * 4, " ")
        LSet strGlob = MAJ & MAJ & MAJ
        Tbl = Split(StrConv(strGlob, vbUnicode), Chr(0))
        For i = 1 To Len(strTemp)
            If Mid(strTemp, i, 1) Like "[a-zA-Z]" Then
                bytAscii = Asc(Mid(strTemp, i, 1))
                If Mid(strTemp, i, 1) = Tbl(bytAscii - DIFFASCIIMAJ) Then
                    Mid(strTemp, i) = Tbl(bytAscii - DIFFASCIIMAJ + lngNumber)
                Else
                    Mid(strTemp, i) = LCase(Tbl(bytAscii - DIFFASCIIMIN + lngNumber))
                End If
            End If
        Next i
    End If
    Caesar_Cipher = strTemp
End Function


COBOL:        identification division.
       program-id. caesar.
       data division.
       1 msg pic x(50)
           value "The quick brown fox jumped over the lazy dog.".
       1 offset binary pic 9(4) value 7.
       1 from-chars pic x(52).
       1 to-chars pic x(52).
       1 tabl.
        2 pic x(26) value "abcdefghijklmnopqrstuvwxyz".
        2 pic x(26) value "ABCDEFGHIJKLMNOPQRSTUVWXYZ".
        2 pic x(26) value "abcdefghijklmnopqrstuvwxyz".
        2 pic x(26) value "ABCDEFGHIJKLMNOPQRSTUVWXYZ".
       procedure division.
       begin.
           display msg
           perform encrypt
           display msg
           perform decrypt
           display msg
           stop run
           .

       encrypt.
           move tabl (1:52) to from-chars
           move tabl (1 + offset:52) to to-chars
           inspect msg converting from-chars
               to to-chars
           .

       decrypt.
           move tabl (1 + offset:52) to from-chars
           move tabl (1:52) to to-chars
           inspect msg converting from-chars
               to to-chars
           .
       end program caesar.
Task: Caesar cipher




Go: package main

import (
    "fmt"
    "strings"
)

type ckey struct {
    enc, dec func(rune) rune
}

func newCaesar(k int) (*ckey, bool) {
    if k < 1 || k > 25 {
        return nil, false
    }
    rk := rune(k)
    return &ckey{
        enc: func(c rune) rune {
            if c >= 'a' && c <= 'z'-rk || c >= 'A' && c <= 'Z'-rk {
                return c + rk
            } else if c > 'z'-rk && c <= 'z' || c > 'Z'-rk && c <= 'Z' {
                return c + rk - 26
            }
            return c
        },
        dec: func(c rune) rune {
            if c >= 'a'+rk && c <= 'z' || c >= 'A'+rk && c <= 'Z' {
                return c - rk
            } else if c >= 'a' && c < 'a'+rk || c >= 'A' && c < 'A'+rk {
                return c - rk + 26
            }
            return c
        },
    }, true
}

func (ck ckey) encipher(pt string) string {
    return strings.Map(ck.enc, pt)
}

func (ck ckey) decipher(ct string) string {
    return strings.Map(ck.dec, ct)
}

func main() {
    pt := "The five boxing wizards jump quickly"
    fmt.Println("Plaintext:", pt)
    for _, key := range []int{0, 1, 7, 25, 26} {
        ck, ok := newCaesar(key)
        if !ok {
            fmt.Println("Key", key, "invalid")
            continue
        }
        ct := ck.encipher(pt)
        fmt.Println("Key", key)
        fmt.Println("  Enciphered:", ct)
        fmt.Println("  Deciphered:", ck.decipher(ct))
    }
}






COBOL:        identification division.
       program-id. caesar.
       data division.
       1 msg pic x(50)
           value "The quick brown fox jumped over the lazy dog.".
       1 offset binary pic 9(4) value 7.
       1 from-chars pic x(52).
       1 to-chars pic x(52).
       1 tabl.
        2 pic x(26) value "abcdefghijklmnopqrstuvwxyz".
        2 pic x(26) value "ABCDEFGHIJKLMNOPQRSTUVWXYZ".
        2 pic x(26) value "abcdefghijklmnopqrstuvwxyz".
        2 pic x(26) value "ABCDEFGHIJKLMNOPQRSTUVWXYZ".
       procedure division.
       begin.
           display msg
           perform encrypt
           display msg
           perform decrypt
           display msg
           stop run
           .

       encrypt.
           move tabl (1:52) to from-chars
           move tabl (1 + offset:52) to to-chars
           inspect msg converting from-chars
               to to-chars
           .

       decrypt.
           move tabl (1 + offset:52) to from-chars
           move tabl (1:52) to to-chars
           inspect msg converting from-chars
               to to-chars
           .
       end program caesar.
Task: Caesar cipher






PHP: <?php
function caesarEncode( $message, $key ){
    $plaintext = strtolower( $message );
    $ciphertext = "";
    $ascii_a = ord( 'a' );
    $ascii_z = ord( 'z' );
    while( strlen( $plaintext ) ){
        $char = ord( $plaintext );
        if( $char >= $ascii_a && $char <= $ascii_z ){
            $char = ( ( $key + $char - $ascii_a ) % 26 ) + $ascii_a;
        }
        $plaintext = substr( $plaintext, 1 );
        $ciphertext .= chr( $char );
    }
    return $ciphertext;
}

echo caesarEncode( "The quick brown fox Jumped over the lazy Dog", 12 ), "\n";
?>
Task: Caesar cipher






PHP: <?php
function caesarEncode( $message, $key ){
    $plaintext = strtolower( $message );
    $ciphertext = "";
    $ascii_a = ord( 'a' );
    $ascii_z = ord( 'z' );
    while( strlen( $plaintext ) ){
        $char = ord( $plaintext );
        if( $char >= $ascii_a && $char <= $ascii_z ){
            $char = ( ( $key + $char - $ascii_a ) % 26 ) + $ascii_a;
        }
        $plaintext = substr( $plaintext, 1 );
        $ciphertext .= chr( $char );
    }
    return $ciphertext;
}

echo caesarEncode( "The quick brown fox Jumped over the lazy Dog", 12 ), "\n";
?>






Ada: with Ada.Text_IO;

procedure Caesar is

   type modulo26 is modulo 26;

   function modulo26 (Character: Character; Output: Character) return modulo26 is
   begin
      return modulo26 (Character'Pos(Character)+Character'Pos(Output));
   end modulo26;

   function Character(Val: in  modulo26; Output: Character)
                        return Character is
   begin
      return Character'Val(Integer(Val)+Character'Pos(Output));
   end Character;

   function crypt (Playn: String; Key: modulo26) return String is
      Ciph: String(Playn'Range);

   begin
      for I in Playn'Range loop
         case Playn(I) is
            when 'A' .. 'Z' =>
               Ciph(I) := Character(modulo26(Playn(I)+Key), 'A');
            when 'a' .. 'z' =>
               Ciph(I) := Character(modulo26(Playn(I)+Key), 'a');
            when others =>
               Ciph(I) := Playn(I);
         end case;
      end loop;
      return Ciph;
   end crypt;

   Text:  String := Ada.Text_IO.Get_Line;
   Key: modulo26 := 3; 

begin 

   Ada.Text_IO.Put_Line("Playn 
   Text := crypt(Text, Key);
   Ada.Text_IO.Put_Line("Ciphertext 
   Ada.Text_IO.Put_Line("Decrypted Ciphertext ->" & crypt(Text, -Key));

end Caesar;
Task: Caesar cipher






PHP: <?php
function caesarEncode( $message, $key ){
    $plaintext = strtolower( $message );
    $ciphertext = "";
    $ascii_a = ord( 'a' );
    $ascii_z = ord( 'z' );
    while( strlen( $plaintext ) ){
        $char = ord( $plaintext );
        if( $char >= $ascii_a && $char <= $ascii_z ){
            $char = ( ( $key + $char - $ascii_a ) % 26 ) + $ascii_a;
        }
        $plaintext = substr( $plaintext, 1 );
        $ciphertext .= chr( $char );
    }
    return $ciphertext;
}

echo caesarEncode( "The quick brown fox Jumped over the lazy Dog", 12 ), "\n";
?>




COBOL:        identification division.
       program-id. caesar.
       data division.
       1 msg pic x(50)
           value "The quick brown fox jumped over the lazy dog.".
       1 offset binary pic 9(4) value 7.
       1 from-chars pic x(52).
       1 to-chars pic x(52).
       1 tabl.
        2 pic x(26) value "abcdefghijklmnopqrstuvwxyz".
        2 pic x(26) value "ABCDEFGHIJKLMNOPQRSTUVWXYZ".
        2 pic x(26) value "abcdefghijklmnopqrstuvwxyz".
        2 pic x(26) value "ABCDEFGHIJKLMNOPQRSTUVWXYZ".
       procedure division.
       begin.
           display msg
           perform encrypt
           display msg
           perform decrypt
           display msg
           stop run
           .

       encrypt.
           move tabl (1:52) to from-chars
           move tabl (1 + offset:52) to to-chars
           inspect msg converting from-chars
               to to-chars
           .

       decrypt.
           move tabl (1 + offset:52) to from-chars
           move tabl (1:52) to to-chars
           inspect msg converting from-chars
               to to-chars
           .
       end program caesar.