Discussions
Narrative Insights is Temporarily Unavailable due to an Infrastructure Issue. Learn how This Impacts Your Account and What to Expect While the Feature is Disabled.
Convert Java code to Netsuite Script for Two factor Security Protocol Authentication for API Integra
We are trying to implement 2 factor authentication for third party REST API in Netsuite. I keep running into issues with AES decryption part. Please see the example of the code below in Java. I need to convert it into suitescript.
public static String decrypt(String encryptedData, String key) throws Exception
{
byte[] keyData = new byte[16];
System.arraycopy(key.getBytes(Charset.forName("UTF-8")), 0, keyData, 0, key.length());
Key secretKey = new SecretKeySpec(keyData, ALGO);
Cipher c = Cipher.getInstance(ALGO);
c.init(2, secretKey);
return new String(c.doFinal(Base64.decodeBase64(encryptedData)));
}
and this is the test data
decrypt("BjlDBJPu9VkmRJqOy5EgaA==","Test12");
/******challenge******/
BjlDBJPu9VkmRJqOy5EgaA==