Node rsa Library Error [InvalidAsn1Error]: Expected 0x2: got 0x30

Node RSA library, read the key file, add and remove the secret report error

throw newInvalidAsn1Error(‘Expected 0x’ + tag.toString(16) +
^

Error [InvalidAsn1Error]: Expected 0x2: got 0x30

The reason is the key file format problem

Pkcs1: public key (- — begin RSA public key ——) and private key (- — begin RSA private key ——) pkcs8: public key (- — begin RSA public key ——) and private key (- — begin private key—

To put it simply, delete the word RSA in the public key and private key

The node RSA library is formatted in this way.

Read More: