Tags
Asked 1 years ago
25 Feb 2023
Views 435
steave

steave posted

how to calculate SHA-256 hash in php

how to calculate SHA-256 hash in php
steave

steave
answered Feb 25 '23 00:00

SHA-256 hash code in PHP:

 $plaintext = "SHA-256 ";
$hash = hash('sha256', $plaintext);
echo $hash;

This will output the SHA-256 hash code for the string "SHA-256":


bbd07c4fc02c99b97124febf42c7b63b5011c0df28d409fbb486b5a9d2e615ea

Note that the hash() function takes two arguments: the hashing algorithm to use (in this case, 'sha256') and the plaintext string to hash. The function returns the hash code as a hexadecimal string.
Post Answer