Hi, i am facing problem to use encrypt function to encrypt my data using my own key and initialization vector. I need to encrypt data for the posting it to my .net site. I will decrypt the encrypted string in .Net. Thus i have generated the key and initialization vector in .net like that, and i need to encrypt the data using this otherwise i can not decrypt it in my .net site. byte[] key = { 20, 5, 3, 58, 170, 151, 146, 82, 10, 45, 72, 93, 179, 6, 151, 63, 91, 19, 5 ...upto 32}; byte[] IV = {15, 36, 12, 1, 77, 29, 27, 60,73, 13, 4, 2, 6, 1, 21, 61 }; No the problem is this i need to encrypt my data in apex using this and byte is not a valid data type in apex, also i need to represent the key and IV using blob. I have converted my key array to a string array by converting each byte to its hexa decimal equivalent but it not work for me as the string was increased to 64 charactor. Also i am not sure that by this conversion i will lost the actual key or not? I have no idea what to do with this, my code is like that //byte[] key = { 20, 5, 3, 58, 170, 151, 146, 82, 10, 45, 72, 93, 179, 6, 151, 63, 91, 19, 5 ...upto 32}; // byte[] IV = {15, 36, 12, 1, 77, 29, 27, 60,73, 13, 4, 2, 6, 1, 21, 61 }; string key_test ='a5b08661bcbba014f2dc3d38aafa3417'; //9e463392526e2d485db306971f5bdb05';string key_IV ='0588660eb1e5f71d'; //497b19a2a06fd644'; blob key_b = blob.valueof(key_test); blob IV_b = blob.valueof(key_IV); blob data = blob.valueof(inputString) Blob encryptedData = Crypto.encrypt('AES256',key_b ,IV_b, data); string encrypted_str = EncodingUtil.base64Encode(encryptedData); if someone tell me how to encrypt the data for the external site in apex using the key and IV when provided by other as above. i know its challenging but salesforce is the field of challenging people, please help me through this issue, every response to this question will be appreciated. Thanks |
-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
4Questions
-
1Replies