Last active
October 3, 2022 09:09
-
-
Save m-primo/3e1892f4efa3f2c1b7b841c1e3ce12b7 to your computer and use it in GitHub Desktop.
Hash & Verify - sha512 & hex.. php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function hash_hex_sha512($s) { | |
return bin2hex(hash('sha512', $s.bin2hex($s), true)); | |
} | |
function verify_hex_sha512($s, $h) { | |
return (hash_hex_sha512($s) == $h); | |
} | |
$s = "hello there"; | |
$h = hash_hex_sha512($s); | |
var_dump($h); | |
var_dump(verify_hex_sha512($s, $h)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class HexSHA512 { | |
public static final function Hash($s) { | |
return (bin2hex(hash('sha512', $s.bin2hex($s), true))); | |
} | |
public static final function Verify($s, $h) { | |
return (HexSHA512::Hash($s) == $h); | |
} | |
} | |
$s = "hello there"; | |
$h = HexSHA512::Hash($s); | |
var_dump($h); | |
var_dump(HexSHA512::Verify($s, $h)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment