Beispiel #1
0
 function derive($secret, $prefix)
 {
     if (!$secret || !$prefix) {
         WindowsLiveLogin::fatal("Error: derive: secret or prefix is null.");
     }
     $keyLen = 16;
     $key = $prefix . $secret;
     if (function_exists('mhash')) {
         $key = mhash(MHASH_SHA256, $key);
     } else {
         $key = hash("sha256", $key, true);
     }
     if (!$key || strlen($key) < $keyLen) {
         WindowsLiveLogin::debug("Error: derive: Unable to derive key.");
         return;
     }
     return substr($key, 0, $keyLen);
 }