- var_dump: documentation ( source)
- uniqid: documentation ( source)
- microtime: documentation ( source)
- hash: documentation ( source)
- array_rand: documentation ( source)
- base64_encode: documentation ( source)
- str_split: documentation ( source)
<?php
$random_string = function($length) {
$bag = str_split('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789');
$string = '';
while ($length--) {
$string .= $bag[array_rand($bag)];
}
return $string;
};
$client_id = $random_string(16);
$client_secret = base64_encode(hash('sha256', uniqid(microtime(1), true)));
var_dump($client_id);
var_dump($client_secret);