Created
December 29, 2022 23:25
-
-
Save sean3z/e8b85497b7e599d22145932c03ba80dc to your computer and use it in GitHub Desktop.
WOL Apgar routine in 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
<?php | |
echo apgar('password'); //result WaIMMsbf | |
function apgar($a) { | |
if (strlen($a) == 8) { | |
$u = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; | |
for ($i = 0; $i <= 7; $i++) { | |
$r = ($i == 0) ? 0 : ord($a[8 - $i]); | |
$x = (ord($a[$i]) & 1) ? (ord($a[$i]) << 1) & $r : ord($a[$i]) ^ $r; | |
$o[] = substr($u, ($x & 0x3f), 1); | |
} | |
return implode('', $o); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment