• Sidhu
  • NEWBIE
  • 0 Points
  • Member since 2012

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

Hi,

 

We tried to implement a single sign on mechanism of a third party web solution using the Crypto.encrypt method. The third party solution requires that the initialization vector is XOR encoded into the first 16 bytes of the transmitted SSO Token. In java this would be done like this:

 

 

for (int i = 0; i < 16; i++) {
   data[i] ^= INIT_VECTOR[i];
}

 

 

where data and INIT_VECTOR would be byte arrays. In Apex there's nothing like a byte array and Blob has no methods at all. The XOR operator ^ does exist in Apex but it can only be used with Boolean expressions and Integers. So I can't just use the Strings and do some wild XOR character operations. Does anybody know how I can implement an XOR encryption like in Java or any other programming language using Apex?

 

Thanks for your help and best regards,

Henry