rsa 验签

//校验 sha1WithRSA 签名

  public function verifySign($data, $sign, $pubKey){
    $sign = base64_decode($sign);
    
    $pubKey = "-----BEGIN PUBLIC KEY-----\n" .
    
    wordwrap($pubKey, 64, "\n", true) .
    
    "\n-----END PUBLIC KEY-----";
    
    $key = openssl_pkey_get_public($pubKey);
    
    $result = openssl_verify($data, $sign, $key, OPENSSL_ALGO_SHA1) === 1;
    
    return $result;
    
    }

 

posted @ 2021-05-17 10:56  子岚天羽卿怜水  阅读(25)  评论(0编辑  收藏  举报