Skip to content

Instantly share code, notes, and snippets.

@CyanoFresh
Last active May 15, 2019 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CyanoFresh/058acbc591e0280b10fb to your computer and use it in GitHub Desktop.
Save CyanoFresh/058acbc591e0280b10fb to your computer and use it in GitHub Desktop.
Generate Steam DeviceID by SteamID for accepting mobile confirmations
<?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