WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Самая быстрая Тема-конструктор для WordPress
функция не описана

ParagonIE_Sodium_File::sign_core32() private WP 1.0

Sign a file (rather than a string). Uses less memory than ParagonIE_Sodium_Compat::crypto_sign_detached(), but produces the same result. (32-bit)

{} Это метод класса: ParagonIE_Sodium_File{}

Хуков нет.

Возвращает

Строку. Ed25519 signature

Использование

$result = ParagonIE_Sodium_File::sign_core32( $filePath, $secretKey );
$filePath(строка) (обязательный)
Absolute path to a file on the filesystem
$secretKey(строка) (обязательный)
Secret signing key

Код ParagonIE_Sodium_File::sign_core32() WP 5.5.2

<?php
private static function sign_core32($filePath, $secretKey)
{
    /** @var int|bool $size */
    $size = filesize($filePath);
    if (!is_int($size)) {
        throw new SodiumException('Could not obtain the file size');
    }
    /** @var int $size */

    /** @var resource|bool $fp */
    $fp = fopen($filePath, 'rb');
    if (!is_resource($fp)) {
        throw new SodiumException('Could not open input file for reading');
    }
    /** @var resource $fp */

    /** @var string $az */
    $az = hash('sha512', self::substr($secretKey, 0, 32), true);

    $az[0] = self::intToChr(self::chrToInt($az[0]) & 248);
    $az[31] = self::intToChr((self::chrToInt($az[31]) & 63) | 64);

    $hs = hash_init('sha512');
    hash_update($hs, self::substr($az, 32, 32));
    /** @var resource $hs */
    $hs = self::updateHashWithFile($hs, $fp, $size);

    /** @var string $nonceHash */
    $nonceHash = hash_final($hs, true);

    /** @var string $pk */
    $pk = self::substr($secretKey, 32, 32);

    /** @var string $nonce */
    $nonce = ParagonIE_Sodium_Core32_Ed25519::sc_reduce($nonceHash) . self::substr($nonceHash, 32);

    /** @var string $sig */
    $sig = ParagonIE_Sodium_Core32_Ed25519::ge_p3_tobytes(
        ParagonIE_Sodium_Core32_Ed25519::ge_scalarmult_base($nonce)
    );

    $hs = hash_init('sha512');
    hash_update($hs, self::substr($sig, 0, 32));
    hash_update($hs, self::substr($pk, 0, 32));
    /** @var resource $hs */
    $hs = self::updateHashWithFile($hs, $fp, $size);

    /** @var string $hramHash */
    $hramHash = hash_final($hs, true);

    /** @var string $hram */
    $hram = ParagonIE_Sodium_Core32_Ed25519::sc_reduce($hramHash);

    /** @var string $sigAfter */
    $sigAfter = ParagonIE_Sodium_Core32_Ed25519::sc_muladd($hram, $az, $nonce);

    /** @var string $sig */
    $sig = self::substr($sig, 0, 32) . self::substr($sigAfter, 0, 32);

    try {
        ParagonIE_Sodium_Compat::memzero($az);
    } catch (SodiumException $ex) {
        $az = null;
    }
    fclose($fp);
    return $sig;
}