简体   繁体   中英

Node.Js Crypto - Sign and Unsign JSON

I am using the following function to sign a JSON with a PrivateKey.

    function createSignature(policy, privateKey) {
        var sign = crypto.createSign('RSA-SHA1');
        sign.update(JSON.stringify(policy));
        return sign.sign(privateKey, 'base64');
      }

Is there a way to unsign/decode the result? I can only find the verify() class in the documentation. But this true/false result is not enough. I want to see the policy json.

Your createSignature function returns a signature of input. Main use of signature is to verify that original data is correct. It's not an encryption algorithm at all. So, answer to your question is "no", you cannot generated a text from a signature in general.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM