performCharTranslate (codePoint, index, content, isEncode) {
    let alphabet = this.getSettingValue('alphabet')
    let charIndex = alphabet.indexOfCodePoint(codePoint)

    if (charIndex === -1) {
      // characters not in alphabet
      if (!this.getSettingValue('includeForeignChars')) {
        // return null character
        return 0
      } else {
        // leave it unchanged
        return codePoint
      }
    }

    // get key code point for this character index
    let key = this.getSettingValue('key')
    let keyIndex = MathUtil.mod(index, key.getLength())
    let keyCodePoint = key.getCodePointAt(keyIndex)

    // determine shift by position in alphabet and inverse it if decoding
    let shift = alphabet.indexOfCodePoint(keyCodePoint) * (isEncode ? 1 : -1)

    // shift character index
    charIndex = MathUtil.mod(charIndex + shift, alphabet.getLength())
    return alphabet.getCodePointAt(charIndex)
  }
/**
   * Performs encode or decode on given character, index and content.
   * @protected
   * @param {number} codePoint Unicode code point
   * @param {number} index Unicode code point index inside content.
   * @param {Chain} content Content to be translated.
   * @param {boolean} isEncode True for encoding, false for decoding.
   * @return {number} Resulting Unicode code point
   */
Performs encode or decode on given character, index and content.
@protected
@param {number} codePoint Unicode code point
@param {number} index Unicode code point index inside content.
@param {Chain} content Content to be translated.
@param {boolean} isEncode True for encoding, false for decoding.
@return {number} Resulting Unicode code point
Performs encode or decode on given character index and content . @protected @param { number } codePoint Unicode code point @param { number } index Unicode code point index inside content . @param { Chain } content Content to be translated . @param { boolean } isEncode True for encoding false for decoding . @return { number } Resulting Unicode code point
performCharTranslate (codePoint, index, content, isEncode) {
    let alphabet = this.getSettingValue('alphabet')
    let charIndex = alphabet.indexOfCodePoint(codePoint)
    if (charIndex === -1) {
      if (!this.getSettingValue('includeForeignChars')) {
        return 0
      } else {
        return codePoint
      }
    }
    let key = this.getSettingValue('key')
    let keyIndex = MathUtil.mod(index, key.getLength())
    let keyCodePoint = key.getCodePointAt(keyIndex)
    let shift = alphabet.indexOfCodePoint(keyCodePoint) * (isEncode ? 1 : -1)
    charIndex = MathUtil.mod(charIndex + shift, alphabet.getLength())
    return alphabet.getCodePointAt(charIndex)
  }
performCharTranslate ( codePoint , index , content , isEncode ) { let alphabet = this . getSettingValue ( 'alphabet' ) let charIndex = alphabet . indexOfCodePoint ( codePoint ) if ( charIndex === - 1 ) { if ( ! this . getSettingValue ( 'includeForeignChars' ) ) { return 0 } else { return codePoint } } let key = this . getSettingValue ( 'key' ) let keyIndex = MathUtil . mod ( index , key . getLength ( ) ) let keyCodePoint = key . getCodePointAt ( keyIndex ) let shift = alphabet . indexOfCodePoint ( keyCodePoint ) * ( isEncode ? 1 : - 1 ) charIndex = MathUtil . mod ( charIndex + shift , alphabet . getLength ( ) ) return alphabet . getCodePointAt ( charIndex ) }
Performs encode or decode on given character, index and content.
Performs encode or decode on given character index and content .
// characters not in alphabet // return null character // leave it unchanged // get key code point for this character index // determine shift by position in alphabet and inverse it if decoding // shift character index