'RSA key conversion from Uint8Array to BigInteger with node-rsa

I have a generated RSA key in the format of Uint8Array but I need the key in the format of BigInteger. See images below. How can I achieve such a conversion?

enter image description here

enter image description here

I use the node RSA lib: https://www.npmjs.com/package/node-rsa



Solution 1:[1]

I am guessing that the ‘generated’ key was obtained by invoking the exportKey method, using the ‘components’ format. With this setting, this method returns a fixed-structure object whose values are Buffers holding individual key components; it also appears that you have installed some kind of shim that simulates the node.js Buffer API with the Uint8Array object that browsers provide.

If that is so, then it all it should take to get the key object back is to invoke the importKey method:

const key = new NodeRSA();
key.importKey(keyData, 'components');

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user3840170