You need to sign in to do that
Don't have an account?
davidwat
how to represent a byte array in apex?
Can someone tell me how to represent a byte array in apex? Say i have a byte array byte[] vk = {1,24,45,26,75}; is there is some way to write this array in salesforce? please replay, the answer that solve this will be selected as a best answer. thanks |
Call the decodeBase64() method and pass the parameter as string (all values with comma seperated) it will convert your input in to byte array and it returns byte array.
can you tell me how? i have tried those two ways and its not work for me
EncodingUtil.base64Decode('a','b','1'); //Method does not exist or incorrect signature
EncodingUtil.base64Decode('a,b,1'); //compiler error , is not a valid base64 charactor.
please help me out here, if have an array like byte[] k={a, b,1 };
how i can convert it into blob of three bytes.
I am not sure but try with following way.
String data='a,b,1';
Blob key = Crypto.generateAesKey(128);
Blob data = Blob.valueOf(data);
// It will encode in base 64
String b64Data = EncodingUtil.base64Encode(data);
// following will be use for encript and descipt
Blob encryptedData= Crypto.encryptWithManagedIV('AES128', key, data);
Blob decryptedData = Crypto.decryptWithManagedIV('AES128', key, encryptedData);
String b64Decrypted = EncodingUtil.base64Encode(decryptedData);
Navneet
But if you want to convert a collection of strings into a single Blob there is a way to do it in Apex which I found through research as there is no clear documentation on doing this.
Here is how you will do it.
Hope this helps!
BTW thank you very much for this solution...look forward to implementing it in my project