Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.5 kB
4
Indexable
Never
  // Your Paddle 'Public Key'
  $public_key_string = '-----BEGIN PUBLIC KEY-----
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAwrAmgxAcX1fVPfUQNvmW
SgAdS4/g4YSzjNK5GjFqUZTY5iIcSuwkAVyFaZp+lQAx2Cl1bM8MkETg8dV3ArWr
NOBtiZ4yHt7mCq0dbGCKirrtzD+9lxwDestiXM4UvM09D0dBZXiGUgJGM0PsIUvo
eXbtOrazzZXWdP+TIzlgHZJ++CYySHEU0Gk3xbuG4xtD/xAcdAN0DVdATcvXhUC+
XSwn8tPP8WII7tRt/G9CiO4ZIDWuVTTFN0wL/kvpQ3RxAail82/zvsMd7+oGI3bP
DSzLLeqhDhLM/rGkQFw0pU4wIZdSj0kNcV+qM0CUD0i2DPCIP5w2TPp7GeCzmDxu
lMwqDL+bdWm19etCQwM76rFxAcHLLk/mSnfOmV1G5kjgcQhfPYo5uq6o+WPD1yVx
IZZazBxZTjgDOcsbIDlkxKjvv2a1zY0oIQ8zpWggoMF+eEbqqK1dhDoi06vjyA4l
vV3QpVUxngMrUnQ+RKT9g2rMALyGY7H6HqNEvPxMLiSz0zADzIqBI5ayQ+pmwH4n
XHQ/DjzHUG88VrfexUMIhx8Z20QXwUxrHusTRnc3WIEu4E/efakAwJ/WEdYQExde
75UdZ/H3MhvyBMgfxhormWW7ANju50JerO92MKNqCzex/Spl90/aKXjGl4FhFJ+1
hFRYG9uJBvUpwkKqOHVuU/kCAwEAAQ==
-----END PUBLIC KEY-----';

  $public_key = openssl_get_publickey($public_key_string);
  
  // Get the p_signature parameter & base64 decode it.
  $signature = base64_decode($_POST['p_signature']);
  
  // Get the fields sent in the request, and remove the p_signature parameter
  $fields = $_POST;
  unset($fields['p_signature']);
  
  // ksort() and serialize the fields
  ksort($fields);
  foreach($fields as $k => $v) {
	  if(!in_array(gettype($v), array('object', 'array'))) {
		  $fields[$k] = "$v";
	  }
  }
  $data = serialize($fields);
  
  // Verify the signature
  $verification = openssl_verify($data, $signature, $public_key, OPENSSL_ALGO_SHA1);
  
  if($verification == 1) {

  .....verified