Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Buffer initialization to non-deprecated method #154

Merged
merged 1 commit into from
Aug 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ function encodeLengthHex(n) {
* Source: http://stackoverflow.com/questions/18835132/xml-to-pem-in-node-js
*/
export function rsaPublicKeyToPEM(modulusB64, exponentB64) {
const modulus = new Buffer(modulusB64, 'base64');
const exponent = new Buffer(exponentB64, 'base64');
const modulus = Buffer.from(modulusB64, 'base64');
const exponent = Buffer.from(exponentB64, 'base64');
const modulusHex = prepadSigned(modulus.toString('hex'));
const exponentHex = prepadSigned(exponent.toString('hex'));
const modlen = modulusHex.length / 2;
Expand All @@ -47,7 +47,7 @@ export function rsaPublicKeyToPEM(modulusB64, exponentB64) {
'02' + encodedModlen + modulusHex +
'02' + encodedExplen + exponentHex;

const der = new Buffer(encodedPubkey, 'hex')
const der = Buffer.from(encodedPubkey, 'hex')
.toString('base64');

let pem = '-----BEGIN RSA PUBLIC KEY-----\n';
Expand Down