<-- Previous || Up || Next -->

Caesar Cipher Function
Codes Ciphers Class

Public Function CaesarCipher( _
      ByVal vMessage As Variant _
    , Optional ByVal vOffset As Variant _
    , Optional ByVal vAlphabet As Variant _
    ) As Variant

Encode or decode a message using the Caesar Cipher.

Summary: The Caesar Cipher works by replacing each character by the one that is some specific number of positions ahead of it within the alphabet.
    CaesarCipher("ATTACK AT DAWN",  3, CryptoAlphabet) = "DWWDFNCDWCGDZQ"
    CaesarCipher("DWWDFNCDWCGDZQ", -3, CryptoAlphabet) = "ATTACK AT DAWN"
See also:
    CaesarCipherSample Subroutine
    CaesarCipherTest Subroutine
    CryptoAlphabet Property
    VigenereCipher Function
vMessage: String containing the message which is to be either encoded or decoded using the Caesar Cipher. Function returns Null if vMessage is Null or cannot be fixed up to a String.

vOffset: Number of character positions that each character within the message should be translated after being looked-up in the alphabet string. With an alphabet of "ABCDEFGHIJKLMNOPQRST" and an offset of 3 (three), "ABCDEF" would become "DEFGHI". vOffset defaults to 3 (three) if it is missing or Null or cannot be fixed up to a number.
Note: Use a positive Offset to encipher (encode) and a negative Offset to decipher (decode).

vAlphabet: String containing the alphabet of characters which is used to encipher or decipher the message. vAlphabet defaults to every character within the character set if it is missing or Null or cannot be fixed up to a String. Function returns Null if vAlphabet is an empty string.

Note: This function will work if the characters in vAlphabet are not in sorted order, but the alphabet should be sorted for the operation to be considered a Caesar Cipher.

Note: Any characters in the message string vMessage which do not appear within the alphabet string vAlphabet will be ignored.

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.