For Walmart I need to decode a key and recode it. ...
# suitescript
s
For Walmart I need to decode a key and recode it. In PHP to decode we d: base64_decode($WalmartPrivateKey) and to encore we do: ConvertPkcs8ToPem() Do you know the equivalent of base64_decode( in netsuite ?
b
it sounds like you are decoding to binary
which means you should not use N/encode
s
OK. What is the equivalent in Netsuite ?
of
base64_decode(
b
keep in mind that NetSuite's handling of binary data is pretty bad
you probably want to at least move up to 2.1 to do so
j
you might just want to import a javascript library that you know will handle the decode
b
that said, you should be looking for an atob polyfill
s
do you know a library that will do it
I'm willing to move to 2.1
j
like @battk said, you will want to look at atob. Just googled and found this one https://www.npmjs.com/package/atob but I havent test it
b
i like the interface on https://www.npmjs.com/package/js-base64, I dont recommend it simply because it implements amd badly and you have to modify the file to make it work
👍 1
j
I couldn't find anything in N/* that handled it, but there's no reason you can't import one of those that meets your needs
b
that said, i think you are the doomed person trying to do Asymmetric Encryption, so expect to do everything the hard way
s
It's required by Walmart
b
to be clear, your best chance at doing this is not to use suitescript
s
I'm using netsuite, what else can I use ?
j
Why not reach out to your PHP server from Netsuite and process the request there?
s
I thought about that too. I feel "bad" about it. We are in netsuite, why not do it in Netsuite. You see ?
b
the answer is that netsuite exposes no libraries to do asymmetric encryption
its unlikely that you can implement rsa yourself, which means you have to hope you can get a library like https://www.npmjs.com/package/node-forge working in netsuite
most of the time they will require some sort of modification since suitescript does not implement the crypto interface