• Yad
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies

I have been able to encrypt and decrypt the body of some JSON requests being sent to and from salesforce.com and a ruby on rails app hosted elsewhere by hardcoding the private key and the IV inside my code as follows:

    string keystring = 'theyKEYrandomstringhereendswith\n';
    string IVstring = 'theIVrandomstringhereendswith\n';
    blob key= EncodingUtil.base64Decode(keystring);
    blob IV = EncodingUtil.base64Decode(IVstring);
    ...
    blob responsetoparseblob2 = crypto.decrypt('AES256',key,IV,responsetoparseblob);

No problems here, except of course that I shouldn't hardcode things like this, but rather place the key and iv in a custom settings object and take the values from there, as follows:

    list<Encryption__c> decrypt = [select key__c,iv__c from Encryption__c where Name='Decrypt' limit 1];
    string key = decrypt[0].key__c;
    string iv =  decrypt[0].iv__c;
    Blob keyval = EncodingUtil.base64Decode(key);
    Blob ivval = EncodingUtil.base64Decode(iv);

Where encryption__c does have the record with the appropriate key and IV. The Key and IV values themselves end with \n.
When the code is executed, I get a "System.StringException: Unrecognized base64 character: \" error on the base64decode lines. This only occurs now that I am pulling these values from a text field in custom settings, but as mentioned earlier, when i just base64decode the key/iv directly, there is no such error.
I have my speculations as to why this is happening, but I'm still not able to resolve it. I tried adding a backslash to perhaps unescape this backslash, only to get a similar error:
"common.apex.runtime.impl.ExecutionException: Unrecognized base64 character: \\\"

Does a value being stored in a field and then stored as a string differ from the same value being stored directly as a string? Is there another function that I should be using to convert the string once it is pulled from custom settings, or is there a daft mistake I am making here that is not apparent to me? Thank you!



  • October 22, 2013
  • Like
  • 0

Hello All,

 

Is it possible to query the storage limit of each org? Is it possible to also query how much of it is being used? I've looked in all the obvious places ($organization) and the docs. All I can find is this information displayed in the UI under company profile, but I would like to access this information programatically.

 

Thanks!
yad 

  • December 03, 2012
  • Like
  • 0

Hello,

 

It seems to me like enhanced lists could be a very useful feature in the design of managed packages. It comes complete with sorting, filtering, creating views, numerical and alphabetical pagination, and of course allowing the selection of multiple records. Rather than reinvent the wheel and make these things from scratch (and suffer the consequences of inconsistent UI/UX), how can I effectively leverage this component in a managed package? My first question is this: How does one go about getting the user's selection?  


Thanks,

yad

  • October 10, 2012
  • Like
  • 0

I have been able to encrypt and decrypt the body of some JSON requests being sent to and from salesforce.com and a ruby on rails app hosted elsewhere by hardcoding the private key and the IV inside my code as follows:

    string keystring = 'theyKEYrandomstringhereendswith\n';
    string IVstring = 'theIVrandomstringhereendswith\n';
    blob key= EncodingUtil.base64Decode(keystring);
    blob IV = EncodingUtil.base64Decode(IVstring);
    ...
    blob responsetoparseblob2 = crypto.decrypt('AES256',key,IV,responsetoparseblob);

No problems here, except of course that I shouldn't hardcode things like this, but rather place the key and iv in a custom settings object and take the values from there, as follows:

    list<Encryption__c> decrypt = [select key__c,iv__c from Encryption__c where Name='Decrypt' limit 1];
    string key = decrypt[0].key__c;
    string iv =  decrypt[0].iv__c;
    Blob keyval = EncodingUtil.base64Decode(key);
    Blob ivval = EncodingUtil.base64Decode(iv);

Where encryption__c does have the record with the appropriate key and IV. The Key and IV values themselves end with \n.
When the code is executed, I get a "System.StringException: Unrecognized base64 character: \" error on the base64decode lines. This only occurs now that I am pulling these values from a text field in custom settings, but as mentioned earlier, when i just base64decode the key/iv directly, there is no such error.
I have my speculations as to why this is happening, but I'm still not able to resolve it. I tried adding a backslash to perhaps unescape this backslash, only to get a similar error:
"common.apex.runtime.impl.ExecutionException: Unrecognized base64 character: \\\"

Does a value being stored in a field and then stored as a string differ from the same value being stored directly as a string? Is there another function that I should be using to convert the string once it is pulled from custom settings, or is there a daft mistake I am making here that is not apparent to me? Thank you!



  • October 22, 2013
  • Like
  • 0

Hello All,

 

Is it possible to query the storage limit of each org? Is it possible to also query how much of it is being used? I've looked in all the obvious places ($organization) and the docs. All I can find is this information displayed in the UI under company profile, but I would like to access this information programatically.

 

Thanks!
yad 

  • December 03, 2012
  • Like
  • 0