```var cipher = crypto.createCipher({ algorith...
# suitescript
m
Copy code
var cipher = crypto.createCipher({
    algorithm: crypto.EncryptionAlg.AES,
    key: crypto.createSecretKey({
        encoding: encode.Encoding.UTF_8,
        secret: 'custsecret_stored_in_netsuite_secrets'
    }),
    padding: crypto.Padding.PKCS5Padding
})
cipher.update({
    input: JSON.stringify(data)
})
var encrypted_result = cipher.final({
    outputEncoding: encode.Encoding.HEX
})
//deliver encrypted_result.iv and encrypted_result.ciphertext to Node.js
b
you did not get your secret key out of a respectable program if its encoded in utf-8
m
@battk I'm getting it out of the Netsuite Secrets Storage (Setup->Company->Secrets). I believe I can specify any encoding for that, correct? Am I wrong with that though?
b
you can specify any encoding you wish
but actual programs that generate the keys used for aes dont output utf-8
specifically since the keys represent binary data, and utf-8 cant represent most binary data
m
Got it. Thanks!
b
typically openssl is a good first place to start for this kind of thing
its been around for a long time
the enc command is capable of generating keys from a passhrase (you dont actually use the passhrase with netsuite, it has no key generation code)
then you can try using openssl to decrypt the encoded text from netsuite