SHARE
TWEET

openssl_verify

krot Aug 19th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3.  
  4. //Данные для генерации сигнатуры
  5. $data = 'my data';
  6.  
  7. //Создаем новую пару открытый/закрытый ключ
  8. $new_key_pair = openssl_pkey_new(array(
  9.     "private_key_bits" => 512,
  10.     "private_key_type" => OPENSSL_KEYTYPE_RSA,
  11. ));
  12. openssl_pkey_export($new_key_pair, $private_key_pem);
  13.  
  14. $details = openssl_pkey_get_details($new_key_pair);
  15.  
  16.  
  17. // print_r($details);
  18. //echo $private_key_pem;
  19.  
  20. openssl_sign($data, $signature, $private_key_pem, OPENSSL_ALGO_SHA256);
  21.  
  22.  
  23. echo openssl_verify ($data , $signature , $details['key'], OPENSSL_ALGO_SHA256);
  24.                
  25.                
  26. //echo $signature;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top