Skip to content

Instantly share code, notes, and snippets.

@alexey-sh
Forked from nolim1t/sign.js
Created August 14, 2019 21:51
Show Gist options
  • Select an option

  • Save alexey-sh/73fc63b6bf2427cc6e890a79766976e4 to your computer and use it in GitHub Desktop.

Select an option

Save alexey-sh/73fc63b6bf2427cc6e890a79766976e4 to your computer and use it in GitHub Desktop.

Revisions

  1. @nolim1t nolim1t revised this gist Aug 6, 2015. 1 changed file with 1 addition and 5 deletions.
    6 changes: 1 addition & 5 deletions sign.js
    Original file line number Diff line number Diff line change
    @@ -4,8 +4,4 @@ function encrypt(key, str) {
    var hmac = crypto.createHmac("sha512", key);
    var signed = hmac.update(new Buffer(str, 'utf-8')).digest("base64");
    return signed
    }

    // Samples
    console.log(encrypt("test", "hello world"));
    console.log(encrypt("test", "goodbye world"));
    }
  2. @nolim1t nolim1t created this gist Aug 6, 2015.
    11 changes: 11 additions & 0 deletions sign.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    var crypto = require("crypto");

    function encrypt(key, str) {
    var hmac = crypto.createHmac("sha512", key);
    var signed = hmac.update(new Buffer(str, 'utf-8')).digest("base64");
    return signed
    }

    // Samples
    console.log(encrypt("test", "hello world"));
    console.log(encrypt("test", "goodbye world"));