From 9957231a059674040b6421b6e07424c735ebc9a5 Mon Sep 17 00:00:00 2001 From: ekapratama93 Date: Fri, 11 Dec 2020 14:18:12 +0700 Subject: [PATCH] use crypto-js --- index.js | 10 +++++----- package.json | 5 ++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 00f8127..80234a7 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,5 @@ -var crypto = require('crypto'); +var hmacSha1 = require('crypto-js/hmac-sha1'); +var base64 = require('crypto-js/enc-base64'); /** * @param {[type]} securityKey @@ -256,10 +257,9 @@ Thumbor.prototype = { if (this.THUMBOR_SECURITY_KEY) { - var key = crypto - .createHmac('sha1', this.THUMBOR_SECURITY_KEY) - .update(operation + this.imagePath) - .digest('base64'); + var key = base64.stringify( + hmacSha1(operation + this.imagePath, this.THUMBOR_SECURITY_KEY) + ) key = key.replace(/\+/g, '-').replace(/\//g, '_'); diff --git a/package.json b/package.json index cd1dc3c..0ed1dae 100644 --- a/package.json +++ b/package.json @@ -12,5 +12,8 @@ }, "readme": "Client Thumbor for Node JS", "readmeFilename": "README.md", - "license": "MIT" + "license": "MIT", + "dependencies": { + "crypto-js": "^3.3.0" + } }