You are here

public static function ParagonIE_Sodium_Core_Util::chrToInt in Automatic Updates 8

Same name and namespace in other branches
  1. 7 vendor/paragonie/sodium_compat/src/Core/Util.php \ParagonIE_Sodium_Core_Util::chrToInt()

Cache-timing-safe variant of ord()

@internal You should not use this directly from another application

Parameters

string $chr:

Return value

int

Throws

SodiumException

TypeError

51 calls to ParagonIE_Sodium_Core_Util::chrToInt()
ParagonIE_Sodium_Compat::crypto_sign_ed25519_sk_to_curve25519 in vendor/paragonie/sodium_compat/src/Compat.php
Convert an Ed25519 secret key to a Curve25519 secret key
ParagonIE_Sodium_Compat::increment in vendor/paragonie/sodium_compat/src/Compat.php
Increase a string (little endian)
ParagonIE_Sodium_Compat::pad in vendor/paragonie/sodium_compat/src/Compat.php
ParagonIE_Sodium_Compat::unpad in vendor/paragonie/sodium_compat/src/Compat.php
ParagonIE_Sodium_Core32_BLAKE2b::stringToContext in vendor/paragonie/sodium_compat/src/Core32/BLAKE2b.php
Creates an SplFixedArray containing other SplFixedArray elements, from a string (compatible with \Sodium\crypto_generichash_{init, update, final})

... See full list

File

vendor/paragonie/sodium_compat/src/Core/Util.php, line 126

Class

ParagonIE_Sodium_Core_Util
Class ParagonIE_Sodium_Core_Util

Code

public static function chrToInt($chr) {

  /* Type checks: */
  if (!is_string($chr)) {
    throw new TypeError('Argument 1 must be a string, ' . gettype($chr) . ' given.');
  }
  if (self::strlen($chr) !== 1) {
    throw new SodiumException('chrToInt() expects a string that is exactly 1 character long');
  }

  /** @var array<int, int> $chunk */
  $chunk = unpack('C', $chr);
  return (int) $chunk[1];
}