* Gets Sha256 from string * @param string $hashString the string to create the hash from * @return Future that resolves to the sha256 object * @throws InvalidSha256Exception if the hash is invalid */
(string $hashString)
| 44 | * @throws InvalidSha256Exception if the hash is invalid |
| 45 | */ |
| 46 | public static function TryFromString(string $hashString): Future |
| 47 | { |
| 48 | return async(function () use($hashString) { |
| 49 | if (Sha256::IsValid($hashString)->await()) { |
| 50 | $sha256 = new Sha256(); |
| 51 | $sha256->_hash = $hashString; |
| 52 | return $sha256; |
| 53 | } |
| 54 | throw new InvalidSha256Exception(); |
| 55 | }); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Validates a hash to be a valid sha256 |