sign.php 762 B

12345678910111213141516171819202122232425262728293031
  1. <?PHP
  2. include_once("config.php");
  3. function sign($name)
  4. {
  5. global $signature_key;
  6. return mcrypt_encrypt ( MCRYPT_RIJNDAEL_256 , $signature_key , $name , MCRYPT_MODE_ECB); //Okay, okay, this isn't a signature, it's a cypher.
  7. } //It still gives the same result every time, and I can use it with a key.
  8. function checkSignature($name,$signature,$deBase64=false)
  9. {
  10. if ($deBase64)
  11. {
  12. $name = base64_url_decode($name);
  13. $signature = base64_url_decode($signature);
  14. }
  15. return $signature == base64_url_encode(sign($name));
  16. }
  17. function base64_url_encode($input)
  18. {
  19. return strtr(base64_encode($input), '+/=', '-_,');
  20. }
  21. function base64_url_decode($input)
  22. {
  23. return base64_decode(strtr($input, '-_,', '+/='));
  24. }
  25. ?>