You need to sign in to do that
Don't have an account?
資訊部
How to change this C# code to Apex
Hi guys,
I have big question. How to change this C# code to Apex. I tried but it didn't work. It always give me APEX_ERROR : System.InvalidParameterValueException: Invalid private key. Must be 16 bytes. Can somebody help me, please.
I have big question. How to change this C# code to Apex. I tried but it didn't work. It always give me APEX_ERROR : System.InvalidParameterValueException: Invalid private key. Must be 16 bytes. Can somebody help me, please.
@RestResource(urlMapping='/API_test/*') global class API_test{ global class clsrecords{ global String endpoint{get;set;} global String decrypt{get;set;} } //Get @HttpGet global static List<clsrecords> getrecords(){ Date dToday = System.Today(); Datetime myDateTime = Datetime.now(); Datetime datetimee = myDateTime.addDays(277); String datee = datetimee.format('yyyyMMdd'); String d = EncodingUtil.urlDecode('8806165303', 'utf8'); string key = EncodingUtil.urlDecode(datee,'utf8'); string iv = EncodingUtil.urlDecode('WGXVRMNU', 'utf8'); Blob data = blob.valueof(d); Blob token_key = blob.valueof(key); Blob token_iv = blob.valueof(iv); //Blob decrypt = Crypto.decryptWithManagedIV('AES128', token_key, token_key); //Blob decrypt = Crypto.decrypt('AES256',token_key,token_iv,data); //Blob encrypt = Crypto.encrypt('AES128',data2,token_key,token_iv); Blob encrypt = Crypto.encryptWithManagedIV('AES128', token_key, token_iv ); List<clsrecords> lstcls = new List<clsrecords>(); clsrecords cls = new clsrecords(); cls.decrypt = String.valueof(encrypt); //cls.decrypt = String.valueof(data.size())+String.valueof(token_key.size())+String.valueof(token_iv.size()); lstcls.add(cls); return lstcls; } }