When customers would like to use Advanced Encryption Algorithm (AES) method of encryption. The key passed on as the third parameter should be padded accordingly.
Using the "Hello" example, the ASCII characters "Hello" are 48656C6C6F in hexadecimal and 11 decimal = 0x0B.
The string given should be converted to Hexadecimal and padded to 16 bytes to complete a 128 bit encryption.
For your reference , please refer to this link http://www.di-mgt.com.au/cryptopad.html#exampleaes.
Sample code using key string 'Hello' and padded by 11 decimal = 0x0B:
var encryptCode= nlapiEncrypt("Testing", "aes", "48656C6C6F0B0B0B0B0B0B0B0B0B0B0B");
var decrypted= nlapiDecrypt(encryptCode, "aes", "48656C6C6F0B0B0B0B0B0B0B0B0B0B0B");
Results:
encryptCode = "c26fe49a0e39331add1a7cab7bd87eeb"
decrypted = "Testing"
----------------------------------------------
Syntax: nlapiEncrypt(s, type, key)
Where:
s = the string value that you want to encrypt.
type = base64, aes, xor
key = Unique string value that would serve as a 'password' in the decryption.
Syntax: nlapiDecrypt(s, type, key)
Where:
s = the string value returned by the nlapiEncrypt
type = the encryption type used on the nlapiEncrypt
key = Unique string value used on the nlapiEncrypt.
great
ReplyDelete