So how do you generate the guid for key generation
# suitescript
t
So how do you generate the guid for key generation
b
What does your secret key field setup look like
t
Like in the script?
I'm really not sure. We weren't using the suitescript stuff before. We were using cryptojs but that breaks in IE
So I am starting from scratch with this
We don't have a field, we are trying to pull it in from a file
b
netsuite's built in crypto tools use guid strings generated from secret key and credential fields
you don't have the option of storing the secret key in a file
t
Ah ok
b
reconsider how desperate you are to use netsuite's built in crypto tools. They are not user friendly.
t
I would rather use what we already have, the only issue is they don't work in IE
And they definitely don't seem to be lol
We're doing stuff with tokens, not passwords so the NS ones are kind of useless to us then lol
b
if you want, you can share what you are doing with crypto js and ill tell you if its possible in NetSuite
t
Copy code
function encrypt (msg, pass) {
  var salt = CryptoJS.lib.WordArray.random(128/8);

  var key = CryptoJS.PBKDF2(pass, salt, {
      keySize: keySize/32,
      iterations: iterations
    });

  var iv = CryptoJS.lib.WordArray.random(128/8);

  var encrypted = CryptoJS.AES.encrypt(msg, key, {
    iv: iv,
    padding: CryptoJS.pad.Pkcs7,
    mode: CryptoJS.mode.CBC

  });

  // salt, iv will be hex 32 in length
  // append them to the ciphertext for use  in decryption
  var transitmessage = salt.toString()+ iv.toString() + encrypted.toString();
  return transitmessage;
}
That's basically what we are doing for encryption. The pass is the token for us, I think
It's from that sites demo
The issue, from what I have found, might be in the CryptoJs.WordArray.random()
I don't think IE supports that, for some reason
b
NetSuite only supports PKCS5
t
Ooooooooo that could be it
Wait, but that should break on chrome then too
Well, we aren't using the token to do calls to other suitelets. It's for calls to an external API
b
i also don't think it supports PBKDF2 (it might if you know how to do it via code). You would need to store the raw secret key instead of the passphrase used to derive the secret key
i meant more along the lines that netsuite's crypto related modules only support PKCS5 and has no explicit support for PBKDF2 (but supports the primitives needed to implement PBKDF2 and supports an alternative of using an actual secret key instead of a derived one)
t
Ah ok, I'd have to see if PKCS5 would work. From the looks of it, we just used what that tutorial used.
I'm under the assumption that if netsuite uses it, it would suffice for us
b
i would assume the opposite, make crypto-js work before trying NetSuite's crypto
i took a look at the code in WordArray, nothing in it should prevent it from working in internet explorer
t
I'm going back through the flow now. The error is thrown when the page loads. So it might not be crypto-js since we have that in the suitelet
Ok, it does look like we are doing decryption
But it's done on a button press not on page load