Vigenere Class
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
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
- _substituteCharCode
- Cipher static
- crypt
- Decipher static
Methods
_rotate
(
Number
protected
-
charCode
Return the rotated charCode.
Parameters:
-
charCode
Numberthe charCode to rotate
Returns:
Number:
(charCode + shift) % 26
_substituteCharCode
(
Number
protected
-
charCode
Substitutes only charCodes of A..Z
and a..z
characters.
Parameters:
-
charCode
Numberthe charCode to substitute.
Returns:
Number:
The substituted charCode.
Cipher
(
Vigenere
static
-
password
Static factory method to create cipher instances.
Returns:
Vigenere:
The Cipher.