ParagonIE\Halite\File::checksum PHP 메소드

checksum() 공개 정적인 메소드

Calculate the BLAKE2b-512 checksum of a file. This method doesn't load the entire file into memory. You may optionally supply a key to use in the BLAKE2b hash.
public static checksum ( string | resource $filePath, Key $key = null, boolean $raw = false ) : string
$filePath string | resource The file
$key Key (optional; expects SignaturePublicKey or AuthenticationKey)
$raw boolean Defaults to returning a hexadecimal string.
리턴 string The checksum
    public static function checksum($filePath, Key $key = null, $raw = false) : string
    {
        if (\is_resource($filePath) || \is_string($filePath)) {
            $readOnly = new ReadOnlyFile($filePath);
            $checksum = self::checksumData($readOnly, $key, $raw);
            $readOnly->close();
            return $checksum;
        }
        throw new InvalidType('Argument 1: Expected a filename or resource');
    }

Same methods

File::checksum ( string | resource $filePath, Key $key = null, mixed $encoding = Halite::ENCODE_BASE64URLSAFE ) : string

Usage Example

예제 #1
0
 /**
  * UpdateFile constructor.
  * @param array $data
  */
 public function __construct(array $data)
 {
     $this->path = $data['path'];
     $this->version = $data['version'];
     $this->size = (int) ($data['size'] ?? \filesize($data['path']));
     $this->hash = File::checksum($data['path']);
 }
All Usage Examples Of ParagonIE\Halite\File::checksum