public static function ParagonIE_Sodium_Core_BLAKE2b::stringToContext in Automatic Updates 8
Same name and namespace in other branches
- 7 vendor/paragonie/sodium_compat/src/Core/BLAKE2b.php \ParagonIE_Sodium_Core_BLAKE2b::stringToContext()
Creates an SplFixedArray containing other SplFixedArray elements, from a string (compatible with \Sodium\crypto_generichash_{init, update, final})
@internal You should not use this directly from another application
@psalm-suppress MixedArrayAssignment
Parameters
string $string:
Return value
Throws
SodiumException
TypeError
2 calls to ParagonIE_Sodium_Core_BLAKE2b::stringToContext()
- ParagonIE_Sodium_Crypto::generichash_final in vendor/
paragonie/ sodium_compat/ src/ Crypto.php - Finalize a BLAKE2b hashing context, returning the hash.
- ParagonIE_Sodium_Crypto::generichash_update in vendor/
paragonie/ sodium_compat/ src/ Crypto.php - Update a hashing context for BLAKE2b with $message
File
- vendor/
paragonie/ sodium_compat/ src/ Core/ BLAKE2b.php, line 742
Class
- ParagonIE_Sodium_Core_BLAKE2b
- Class ParagonIE_Sodium_Core_BLAKE2b
Code
public static function stringToContext($string) {
$ctx = self::context();
# uint64_t h[8];
for ($i = 0; $i < 8; ++$i) {
$ctx[0][$i] = SplFixedArray::fromArray(array(
self::load_4(self::substr($string, ($i << 3) + 4, 4)),
self::load_4(self::substr($string, ($i << 3) + 0, 4)),
));
}
# uint64_t t[2];
# uint64_t f[2];
for ($i = 1; $i < 3; ++$i) {
$ctx[$i][1] = SplFixedArray::fromArray(array(
self::load_4(self::substr($string, 76 + ($i - 1 << 4), 4)),
self::load_4(self::substr($string, 72 + ($i - 1 << 4), 4)),
));
$ctx[$i][0] = SplFixedArray::fromArray(array(
self::load_4(self::substr($string, 68 + ($i - 1 << 4), 4)),
self::load_4(self::substr($string, 64 + ($i - 1 << 4), 4)),
));
}
# uint8_t buf[2 * 128];
$ctx[3] = self::stringToSplFixedArray(self::substr($string, 96, 256));
# uint8_t buf[2 * 128];
$int = 0;
for ($i = 0; $i < 8; ++$i) {
$int |= self::chrToInt($string[352 + $i]) << ($i << 3);
}
$ctx[4] = $int;
return $ctx;
}