caesar-salad

API Docs for: v2.0.1
Show:

Vigenere Class

Defined in: vigenere.js:8
Module: caesar-salad

The Vigenere Cipher is a polylphabetic substitution cipher rotating A..Z and a..z characters:

Examples using static factory methods:

Vigenere.Cipher('abc').crypt('ABAB');   // returns: 'ACCB'

var cipher = Vigenere.Cipher('abc');
cipher.crypt('AB');                     // returns: 'AC'
cipher.crypt('AB');                     // returns: 'CB'

Vigenere.Decipher('abc').crypt('ACCB'); // returns 'ABAB'

Examples using constructors:

new Vigenere([0, 1, 2]).crypt('ABAB');  // returns: 'ACCB'
new Vigenere([0,-1,-2]).crypt('ACCB');  // returns: 'ABAB'
new Vigenere([0,25,24]).crypt('ACCB');  // returns: 'ABAB'

See Wikipedia for details.

Constructor

Vigenere

(
  • shiftArray
)

Defined in vigenere.js:8

Parameters:

  • shiftArray [Number]

    The array of numbers used to rotate the charCodes mod 26 and therefore the password of the Vigenere Cipher.

Item Index

Methods

_rotate

(
  • charCode
)
Number protected

Defined in vigenere.js:51

Return the rotated charCode.

Parameters:

  • charCode Number

    the charCode to rotate

Returns:

Number:

(charCode + shift) % 26

_substituteCharCode

(
  • charCode
)
Number protected

Inherited from SubstitutionCipher but overwritten in vigenere.js:40

Substitutes only charCodes of A..Z and a..z characters.

Parameters:

  • charCode Number

    the charCode to substitute.

Returns:

Number:

The substituted charCode.

Cipher

(
  • password
)
Vigenere static

Defined in vigenere.js:66

Static factory method to create cipher instances.

Parameters:

Returns:

Vigenere:

The Cipher.

crypt

(
  • input
)
Number

Template method to encrypt/decrypt strings substituting its input charCode by charCode.

Parameters:

  • input String

    The string to process.

Returns:

Number:

The processed string.

Decipher

(
  • password
)
Vigenere static

Defined in vigenere.js:78

Static factory method to create decipher instances.

Parameters:

Returns:

Vigenere:

The Decipher.