You need to sign in to do that
Don't have an account?
16Byte Hexadecimal value is changed to 32Bytes when it is converted as Blob
I am having a hexadecimal value of 32 characters which I am storing in String(as salesforce do not have any data type for hexadecimal). When I am converting this String to Blob and using the blob for encryption, the blob size is changed to 32Bytes (each character is been considered as 1 byte unlike the regular hexadecimal where 2 characters make a byte). Can any one please let me know how to store hexadecimal values in Salesforce and how to convert it accordingly so that the size does not change. Or do we have any way to convert it to blob where we get only 16bytes instead of 32 bytes
You have to store the BASE64 form of your key, not the hex form. Storing the key as a hex string really does make it 32 bytes, not the orginal 16. To get the Blob from the BASE64 string, use the EncodingUtil.base64decode(String) function.
Here is an example case:
Thanks for your reply. I have actually performed the same and have got the result. But I have one more problem, I have integer to be encrypted but encryptionwithManagedIV will take only blob.valueOf(string). can you please help me out with this
String keyAsBase64 = 'RjFuJHRyb0ludGVncmF0aW9uJA==';
Blob keyAsBlob = EncodingUtil.base64Decode(keyAsBase64);
I need to 32bit User key for Integrationg Salesforce in a HTML POST page, How can I get 32bit User Key for my password