User:SignpostMarv Martin/PHP/llXorBase64StringsCorrect

From Second Life Wiki
< User:SignpostMarv Martin
Revision as of 07:53, 3 October 2010 by SignpostMarv Martin (talk | contribs) (98 bytes shorter, does exactly the same thing)
Jump to navigation Jump to search

The following code is an implementation of llXorBase64StringsCorrect() in PHP.

This simple function should be useful if you're using llXorBase64StringsCorrect() to do cryptography work in LSL2.

Feel free to use it, as it's published under the same Creative Commons license as this entire Wiki (BY-SA).

<php><?php

function llXorBase64StringsCorrect($s1,$s2){

  1. Description: Implementation of the LSL2 function llXorBase64StringsCorrect()
  2. Author: SignpostMarv Martin
  3. Released under http://creativecommons.org/licenses/by-sa/2.5/

$l1 = strlen($s1 = base64_decode($s1)); $s2 = base64_decode($s2); return base64_encode($s1 ^ (strlen($s1) > strlen($s2) ? str_pad($s2, $l1, $s2, STR_PAD_RIGHT) : $s2)); }

?></php>