Thanks in advance
# suitescript
m
Thanks in advance
n
What exactly is the problem? 🙂 Post any errors and code here and it's gonna be easier for people to help.
m
I am using jsencrypt.js libary for it. Below is sample code
function test() { var clientSecEncoded = 'test'; var headers = new Array(); headers['Content-Type'] = "application/json"; headers['Accept'] = "application/json"; var data = { "clientId" : "test", } var public_key = '-----BEGIN PUBLIC KEY-----'; public_key += 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDlOJu6TyygqxfWT7eLtGDwajtN'; public_key += 'FOb9I5XRb6khyfD1Yt3YiCgQWMNW649887VGJiGr/L5i2osbl8C9+WJTeucF+S76'; public_key += 'xFxdU6jE0NQ+Z+zEdhUTooNRaY5nZiu5PgDB0ED/ZKBUSLKL7eibMxZtMlUDHjm4'; public_key += 'gwQco1KRMDSmXSMkDwIDAQAB'; public_key += '-----END PUBLIC KEY-----'; var obj = new JSEncrypt(); obj.setPublicKey(public_key); var encrypted = obj.encrypt('TestString'); }
----- I got an error like
TypeError: [object Object] is not a function, it is object.
n
What row does the stack trace say the error is on?
l
Hey Mahin. I used an certificate and N/crypto/certificate module to sign some records on Netsuite but it's using a pair of public/private keys. Is that work for you?
m
I need to use public key for throughout
@Nikola Gavric Error is on line var obj= new JSEncypt
n
@Mahin not really sure what it is sorry, could be something with the lib but not sure..
b
you might have to modify this library to use in NetSuite
it exports to window and uses the navigator global
otherwise take a look at the last few lines of jsencrypt.js
it exports to an object with 2 keys: JSEncrypt and default
m
@Nikola Gavric @battk thanks for you help. I will check it.