Last active
May 15, 2019 22:13
-
-
Save CyanoFresh/058acbc591e0280b10fb to your computer and use it in GitHub Desktop.
Generate Steam DeviceID by SteamID for accepting mobile confirmations
This file contains hidden or 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 | |
/** | |
* Generate device id by steamid | |
* Usage: getDeviceID('steamid'); | |
* | |
* @param string $steamid SHOULD BE STRING | |
* @return string | |
*/ | |
function getDeviceID($steamid) { | |
$sha1 = sha1($steamid); | |
$cut = substr($sha1, 0, 32); | |
$deviceID = preg_replace('/^([0-9a-f]{8})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{12}).*$/', '$1-$2-$3-$4-$5', $cut); | |
$prepend = 'android:'; | |
return $prepend . $deviceID; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment