ParagonIE_Sodium_Core32_BLAKE2b::stringToContext() public WP 1.0
Creates an SplFixedArray containing other SplFixedArray elements, from a string (compatible with \Sodium\crypto_generichash_{init, update, final})
{} It's a method of the class: ParagonIE_Sodium_Core32_BLAKE2b{}
No Hooks.
Return
SplFixedArray
. Null. Nothing.
Usage
$result = ParagonIE_Sodium_Core32_BLAKE2b::stringToContext( $string );
- $string(string) (required)
- -
Code of ParagonIE_Sodium_Core32_BLAKE2b::stringToContext() ParagonIE Sodium Core32 BLAKE2b::stringToContext WP 5.7
public static function stringToContext($string)
{
$ctx = self::context();
# uint64_t h[8];
for ($i = 0; $i < 8; ++$i) {
$ctx[0][$i] = ParagonIE_Sodium_Core32_Int64::fromReverseString(
self::substr($string, (($i << 3) + 0), 8)
);
}
# uint64_t t[2];
# uint64_t f[2];
for ($i = 1; $i < 3; ++$i) {
$ctx[$i][1] = ParagonIE_Sodium_Core32_Int64::fromReverseString(
self::substr($string, 72 + (($i - 1) << 4), 8)
);
$ctx[$i][0] = ParagonIE_Sodium_Core32_Int64::fromReverseString(
self::substr($string, 64 + (($i - 1) << 4), 8)
);
}
# 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;
}