Пример #1
0
 /**
  * Sign a base string using the given algoritm (if supported, generate notice otherwise)
  * @param $algo
  * @param $string_to_sign
  * @param $consumer_secret
  * @param $token_secret
  * @return string signiture for the given parms
  */
 public static function sign_base_string($algo, $string_to_sign, $consumer_secret, $token_secret)
 {
     $algo = strtoupper($algo);
     $key = SPUtils::join_encoded3896($consumer_secret, $token_secret);
     if ($algo == "HMAC-SHA1") {
         return base64_encode(hash_hmac("sha1", $string_to_sign, $key, true));
     } else {
         if ($algo == "PLAINTEXT") {
             return SPOAuthClient::rfc3986_encode($key);
         } else {
             trigger_error("{$algo} signature method not supported");
         }
     }
 }