diff --git a/lib/rsa-extra.js b/lib/rsa-extra.js index 2ba7dd1..38a3e77 100644 --- a/lib/rsa-extra.js +++ b/lib/rsa-extra.js @@ -7,7 +7,13 @@ function _bigIntToBase64Url(fbin) { // Invalid hex string hex = '0' + hex; } - var buf = Buffer.from(hex, 'hex'); + var buf; + // See https://github.com/Daplie/rsa-compat.js/issues/9 + try { + buf = Buffer.from(hex, 'hex'); + } catch(e) { + buf = new Buffer(hex, 'hex'); + } var b64 = buf.toString('base64'); var b64Url = b64.replace(/[+]/g, "-").replace(/\//g, "_").replace(/=/g,"");