Skip to content

sha256 ​

Calculate the SHA-256 hash of the string.

php
Twine\Str::sha256( [ bool $mode = Twine\Config\Sha256::DEFAULT ] ) : Twine\Str

Parameters ​

$mode ​

A SHA-256 mode flag.

Available SHA-256 modes:

  • Twine\Config\Sha256::DEFAULT: Return the hash
  • Twine\Config\Sha256::RAW: Return the raw binary of the hash

Examples ​

php
$string = new Twine\Str('john pinkerton');

$string->sha256(); // Returns '7434f26c8c2fc83e57347feb2dfb235c2f47b149b54b80692beca9d565159dfd'