Discussions
Join the NetSuite community to innovate, connect, and discover what’s next.
SuiteWorld brings thousands of innovators, builders, and leaders together to learn, connect, and shape what’s next. This October, explore how to build a stronger foundation for growth through inspiring keynotes, major product reveals, hands-on sessions, and unforgettable moments—all in one place for our biggest event of the year. Register now
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==