Verify and decode the given `val` with `secrets`.

@param {String} val
@param {Array} secrets
@returns {String|Boolean}
@private
545178
function unsigncookie(val, secrets) {
  for (var i = 0; i < secrets.length; i++) {
    var result = signature.unsign(val, secrets[i]);

    if (result !== false) {
      return result;
    }
  }

  return false;
}
909657
function normalize (val, safe) {
    return (
      val == null ? ''
      : val === false ? ''
      : Array.isArray(val) ? val.map(normalize).join('')
      : safe === false ? $.escapeHTML(val)
      : String(val)
    )
  }
770257
function memoize(key, val) {
  if (cache.hasOwnProperty(key)) {
    return cache[key];
  }
  return (cache[key] = val);
}
1237209
def getSymmetricallyEncryptedVal(val, secretKey: Union[str, bytes] = None) -> \
        Tuple[str, str]:
    

    if isinstance(val, str):
        val = val.encode("utf-8")
    if secretKey:
        if isHex(secretKey):
            secretKey = bytes(bytearray.fromhex(secretKey))
        elif not isinstance(secretKey, bytes):
            error("Secret key must be either in hex or bytes")
        box = libnacl.secret.SecretBox(secretKey)
    else:
        box = libnacl.secret.SecretBox()

    return box.encrypt(val).hex(), box.sk.hex()
733601
function secretKey(length, options = {}) {
  if (!length || length < 1) {
    return '';
  }

  if (!options.crypto || typeof options.crypto.randomBytes !== 'function') {
    throw new Error('Expecting options.crypto to have a randomBytes function');
  }

  return options.crypto
    .randomBytes(length)
    .toString('base64') // convert format
    .slice(0, length); // return required number of characters
}
974021
public static function encode($input, $secret = null) {
        // no input?
        if(!$input)
            return false;

        // run xor
        $xored = self::xor((string)$input, self::secret($secret));

        // output
        return self::base64encode($xored);
    }
862016
def decrypt(value)
      return value if is_empty_val(value)
      c = cipher.decrypt
      c.key = Digest::SHA256.digest(cipher_key)
      c.iv = Base64.decode64 value.slice!(0,25)
      c.update(Base64.decode64(value.to_s)) + c.final
    end
1172262
def add(self, value):  # type: (Text) -> Text
        
        if not isinstance(value, string_types):
            raise Exception("Secret store only accepts strings")

        if value not in self.secrets:
            placeholder = "(secret-%s)" % Text(uuid.uuid4())
            self.secrets[placeholder] = value
            return placeholder
        return value
101477
public boolean validSecondFactor(String secret, String number) {
        Objects.requireNonNull(secret, Required.SECRET.toString());
        Objects.requireNonNull(number, Required.TOTP.toString());
        
        return TotpUtils.verifiedTotp(secret, number);
    }
485662
function ustring (val) {
  var str = String(val)

  // percent encode as UTF-8
  var encoded = encodeURIComponent(str)
    .replace(ENCODE_URL_ATTR_CHAR_REGEXP, pencode)

  return 'UTF-8\'\'' + encoded
}
329827
function settingToRegExpInfo(val, defaultDelimiters) {
    if (!val) {
        return {
            pattern: `${defaultDelimiters[0]}([\\s\\S]*?)${
                defaultDelimiters[1]
            }`,
            getDelimiters: () => defaultDelimiters,
        }
    }
    if (Array.isArray(val)) {
        return {
            pattern: `${escapeRegExp(val[0])}([\\s\\S]*?)${escapeRegExp(
                val[1]
            )}`,
            getDelimiters: () => val,
        }
    }

    const source = val instanceof RegExp ? val.source : `${val}`
    const pattern =
        source.indexOf("([\\s\\S]+?)") >= 0
            ? source.replace("([\\s\\S]+?)", "([\\s\\S]*?)")
            : source.indexOf("([\\S\\s]+?)") >= 0
            ? source.replace("([\\S\\s]+?)", "([\\s\\S]*?)")
            : source

    let getDelimiters = undefined
    const delmPattern = pattern.split("([\\s\\S]*?)")
    if (delmPattern.length === 2) {
        const re = new RegExp(
            delmPattern.map(s => `(${s})`).join("([\\s\\S]*?)"),
            "u"
        )
        getDelimiters = (text, innerCode) => {
            const r = text.match(re)
            if (r) {
                return [r[1], r[3]]
            }
            return getDelimitersFinalMeans(text, innerCode)
        }
    } else {
        getDelimiters = getDelimitersFinalMeans
    }
    return {
        pattern,
        getDelimiters,
    }
}
520762
function getcookie(req, name, secrets) {
  var header = req.headers.cookie;
  var raw;
  var val;

  // read from cookie header
  if (header) {
    var cookies = cookie.parse(header);

    raw = cookies[name];

    if (raw) {
      if (raw.substr(0, 2) === 's:') {
        val = unsigncookie(raw.slice(2), secrets);

        if (val === false) {
          debug('cookie signature invalid');
          val = undefined;
        }
      } else {
        debug('cookie unsigned')
      }
    }
  }

  // back-compat read from cookieParser() signedCookies data
  if (!val && req.signedCookies) {
    val = req.signedCookies[name];
  }

  // back-compat read from cookieParser() cookies data
  if (!val && req.cookies) {
    raw = req.cookies[name];

    if (raw) {
      if (raw.substr(0, 2) === 's:') {
        val = unsigncookie(raw.slice(2), secrets);

        if (val === false) {
          debug('cookie signature invalid');
          val = undefined;
        }
      } else {
        debug('cookie unsigned')
      }
    }
  }

  return val;
}
694324
def detect_secrets():
    
    # use
    # blah blah = "foo"     # pragma: whitelist secret
    # to ignore a false posites
    errors_file = "detect-secrets-results.txt"

    print(execute_get_text("pwd"))

    command = "{0} detect-secrets --scan --base64-limit 4 --exclude .idea|.js|.min.js|.html|.xsd|" \
              "lock.json|synced_folders|.scss|Pipfile.lock|" \
              "lint.txt|{1}".format(PIPENV, errors_file).strip()
    print(command)
    bash_process = subprocess.Popen(command.split(" "),
                                    #shell=True,
                                    stdout=subprocess.PIPE,
                                    stderr=subprocess.PIPE
                                    )
    foo = bash_process.wait()
    out, err = bash_process.communicate()  # wait


    with open(errors_file, "w+") as file_handle:
        if len(out)==0:
            print("Warning- no output from detect secrets. Happens with git hook, but not from ordinary command line.")
            return
        file_handle.write(out.decode())



    with open(errors_file) as f:
        try:
            data = json.load(f)
        except Exception:
            print("Can't read json")
            exit(-1)
            return

    if data["results"]:
        for result in data["results"]:
            print(result)
        print("detect-secrets has discovered high entropy strings, possibly passwords?")
        exit(-1)
26530
private function jsEncode($val)
    {
        if (is_null($val)) {
            return 'null';
        }
        if (is_bool($val)) {
            return $val ? 'true' : 'false';
        }
        if (is_int($val)) {
            return $val;
        }
        if (is_float($val)) {
            return str_replace(',', '.', $val);
        }
        if (is_array($val) || is_object($val)) {
            if (is_array($val) && (array_keys($val) === range(0, count($val) - 1))) {
                return '['.implode(',', array_map([$this, 'jsEncode'], $val)).']';
            }
            $temp = [];
            foreach ($val as $k => $v) {
                $temp[] = $this->jsEncode("{$k}").':'.$this->jsEncode($v);
            }

            return '{'.implode(',', $temp).'}';
        }
        // String otherwise
        if (strpos($val, '@@') === 0) {
            return substr($val, 2);
        }
        if (strtoupper(substr($val, 0, 9)) == 'CKEDITOR.') {
            return $val;
        }

        return '"'.str_replace(['\\', '/', "\n", "\t", "\r", "\x08", "\x0c", '"'], ['\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'], $val).'"';
    }
1011009
static public function mysql_aes_encrypt($val, $ky)
    {

        if (empty($ky) && empty($val)) return null;

        $key = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
        for ($a = 0; $a < strlen($ky); $a++) {
            $key[$a % 16] = chr(ord($key[$a % 16]) ^ ord($ky[$a]));
        }
        $mode = MCRYPT_MODE_ECB;
        $enc  = MCRYPT_RIJNDAEL_128;
        $val  = str_pad($val, (16 * (floor(strlen($val) / 16) + (strlen($val) % 16 == 0 ? 2 : 1))), chr(16 - (strlen($val) % 16)));

        return mcrypt_encrypt($enc, $key, $val, $mode, mcrypt_create_iv(mcrypt_get_iv_size($enc, $mode), MCRYPT_DEV_URANDOM));
    }
225029
function _checkIsHttpToken(val) {
	if (typeof val !== 'string' || val.length === 0) {
		return false;
	}
	if (!_isValidTokenChar(val.charCodeAt(0))) {
		return false;
	}
	const len = val.length;
	if (len > 1) {
		if (!_isValidTokenChar(val.charCodeAt(1))) {
			return false;
		}
		if (len > 2) {
			if (!_isValidTokenChar(val.charCodeAt(2))) {
				return false;
			}
			if (len > 3) {
				if (!_isValidTokenChar(val.charCodeAt(3))) {
					return false;
				}
				for (var i = 4; i < len; i++) {
					if (!_isValidTokenChar(val.charCodeAt(i))) {
						return false;
					}
				}
			}
		}
	}
	return true;
}
1016748
function(val) {
			if (typeof val !== 'undefined' && this._name !== (val = String(val))) {
				this._updateSource(val, this._positions.name, this._positions.name + this._name.length);
				this._name = val;
			}
			
			return this._name;
		}