performTranslate (content, isEncode) {
    const { a, b, alphabet, includeForeignChars } = this.getSettingValues()

    const m = alphabet.getLength()
    const n = content.getLength()
    const result = new Array(n).fill(0)

    let codePoint, i, c, x, y
    for (i = 0; i < n; i++) {
      codePoint = content.getCodePointAt(i)

      x = alphabet.indexOfCodePoint(codePoint)
      if (x === -1) {
        // Character not in alphabet
        if (includeForeignChars) {
          // Take over character unchanged
          result[i] = codePoint
        }
      } else {
        if (isEncode) {
          // E(x) = (ax + b) mod m
          y = MathUtil.mod(a * x + b, m)
        } else {
          // D(x) = (a^-1(x - b)) mod m
          c = MathUtil.xgcd(a, m)[0]
          y = MathUtil.mod(c * (x - b), m)
        }
        result[i] = alphabet.getCodePointAt(y)
      }
    }

    return result
  }
/**
   * Performs encode or decode on given content.
   * @param {Chain} content
   * @param {boolean} isEncode True for encoding, false for decoding
   * @return {number[]|string|Uint8Array|Chain|Promise} Resulting content
   */
Performs encode or decode on given content.
Performs encode or decode on given content .
performTranslate (content, isEncode) {
    const { a, b, alphabet, includeForeignChars } = this.getSettingValues()
    const m = alphabet.getLength()
    const n = content.getLength()
    const result = new Array(n).fill(0)
    let codePoint, i, c, x, y
    for (i = 0; i < n; i++) {
      codePoint = content.getCodePointAt(i)
      x = alphabet.indexOfCodePoint(codePoint)
      if (x === -1) {
        if (includeForeignChars) {
          result[i] = codePoint
        }
      } else {
        if (isEncode) {
          y = MathUtil.mod(a * x + b, m)
        } else {
          c = MathUtil.xgcd(a, m)[0]
          y = MathUtil.mod(c * (x - b), m)
        }
        result[i] = alphabet.getCodePointAt(y)
      }
    }
    return result
  }
performTranslate ( content , isEncode ) { const { a , b , alphabet , includeForeignChars } = this . getSettingValues ( ) const m = alphabet . getLength ( ) const n = content . getLength ( ) const result = new Array ( n ) . fill ( 0 ) let codePoint , i , c , x , y for ( i = 0 ; i < n ; i ++ ) { codePoint = content . getCodePointAt ( i ) x = alphabet . indexOfCodePoint ( codePoint ) if ( x === - 1 ) { if ( includeForeignChars ) { result [ i ] = codePoint } } else { if ( isEncode ) { y = MathUtil . mod ( a * x + b , m ) } else { c = MathUtil . xgcd ( a , m ) [ 0 ] y = MathUtil . mod ( c * ( x - b ) , m ) } result [ i ] = alphabet . getCodePointAt ( y ) } } return result }
Performs encode or decode on given content.
Performs encode or decode on given content .
// Character not in alphabet // Take over character unchanged // E(x) = (ax + b) mod m // D(x) = (a^-1(x - b)) mod m