Skip to content

Instantly share code, notes, and snippets.

@icyleaf
Created June 18, 2010 07:26
Show Gist options
  • Select an option

  • Save icyleaf/443359 to your computer and use it in GitHub Desktop.

Select an option

Save icyleaf/443359 to your computer and use it in GitHub Desktop.
consumer_key
<?php
function new_consumer_key()
{
// in case /dev/urandom is reusing entropy from its pool, let's add a bit more entropy
$entropy = uniqid(mt_rand(), true);
$hash = sha1($entropy); // sha1 gives us a 40-byte hash
// The first 30 bytes should be plenty for the consumer_key
// We use the last 10 for the shared secret
return array(
'key' => substr($hash, 0, 30),
'secret'=> substr($hash, 30, 10));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment