login about faq

Hello there,

I'm trying to use RSA lib but its not working to import the public key:

let os = require('os');
if (os.platform() == 'linux') {
  if (os.arch() == 'x86') var chilkat = require('chilkat_linux32');
  else var chilkat = require('chilkat_linux64');
} else if (os.platform() == 'darwin') {
  var chilkat = require('chilkat_macosx');
}

var rsa = new chilkat.Rsa();
if (!rsa.UnlockComponent("Anything for 30-day trial")) throw new Error("RSA component unlock failed");
var rsa_key = "<RSAKeyValue><Modulus>vRndy7JYFnVae/3XCTPGMuwNlFMWrETDkHH2nFP/tnuFDa/n/sh3nZ57LBHu2zpSfLcJ93uXWZ+rCGCxc6lRU4qZU1+WubGXcPeM9ZZDN3uihKn/24YF7Y8KyWPr+QeBz8nNcJyPuPYPbx2YFGx/+AhsZ/KLzk4EoaO5nr/84Of5afWAORFSdt76Ac0tGp3qEvvScIRIy2PdF/9hE4iEYYC+sgy4eAIOjmQXWcuXz3d27fAMDtc3sxZtAb/klkN226sdCUFeTIIxqiOmq17gESYnWFifX55TcboqWmhHLfXCyl8vX/O56lHeNoinCaIQOBg6UrWj1NmOOf/7aevhElictDAJgRCBETuwORPdfJqzfgXS5e1rzMuKRF6qBIGtKLPwnCUgBioZAyqrjaLImQlEphGZJ3DsVPlKn43xo7t8I5HSF8O3TBNY2Zq2yrWaVLiWau5Jmr21k0oY0WS5FLt7HnzasbhcPIPjJ7awM4VtyNcmC8cIr9h9CMAjbXmmh/aX7xI2S0tf5MsUzeOJVXMpVDP7e/6bXh7UMt22omfDsKwqYCt3YtIbioi757TIJ5GQXyLK4Z85iWVneFKI/tvRGrxfkzU8FJRvgPGIUQRBLhy9FE76BACr7RqJZe5aL0e5jugoIwCfnDRQHrHuArcRWhBh1aKmX90KfVi+dOk=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>";

rsa.ImportPublicKey(rsa_key);
rsa.Charset = "utf-8";
rsa.EncodingMode = "base64";
console.log(rsa.LastErrorText);

But the import public key fails without a reason:

ChilkatLog:
  ImportPublicKey:
    DllDate: Oct 29 2015
    ChilkatVersion: 9.5.0.54
    UnlockPrefix: Anything for 30-day trial
    Architecture: Little Endian; 64-bit
    Language: Mac OS X Node.js
    VerboseLogging: 0
    Failed.
  --ImportPublicKey
--ChilkatLog

Im running on OSX.

Even if i try the example code on: http://www.example-code.com/nodejs/rsa_charset.asp The same thing happens...

asked Nov 10 '15 at 12:24

rafaismyname's gravatar image

rafaismyname
1


There's an error in the example, and I'll update it right away. (Sorry about that!)

The XML for an RSA public key should be "<RSAPublicKey> ... </RSAPublicKey>" instead of "<RSAKeyValue> ... </RSAKeyValue>"

link

answered Nov 10 '15 at 14:24

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

ok... but in my case, using the rsa xml key that i provided, what should i do? Rename the key RSAKeyValue to RSAPublicKey? And why the lib cant work with both RSAPublicKey and RSAKeyValue?

thanks

(Nov 11 '15 at 09:20) rafaismyname
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×47
×6
×6
×2

Asked: Nov 10 '15 at 12:24

Seen: 827 times

Last updated: Nov 11 '15 at 09:20

powered by OSQA