Difference between revisions of "User:SignpostMarv Martin/PHP/llXorBase64StringsCorrect"

From Second Life Wiki
Jump to navigation Jump to search
m
m (wiki-fu)
Line 5: Line 5:
Feel free to use it, as it's published under the same Creative Commons license as this entire Wiki [http://creativecommons.org/licenses/by-sa/2.5/ (BY-SA)].
Feel free to use it, as it's published under the same Creative Commons license as this entire Wiki [http://creativecommons.org/licenses/by-sa/2.5/ (BY-SA)].


<div style="font-size:140%;"><code class="php"><pre><nowiki><?php
<div style="font-size:1.4em;"><php><?php
function llXorBase64StringsCorrect($s1,$s2)
function llXorBase64StringsCorrect($s1,$s2)
{
{
# Description: Implementation of the LSL2 function llXorBase64StringsCorrect()
# Description: Implementation of the LSL2 function llXorBase64StringsCorrect()
# Author: SignpostMarv Martin
# Author: SignpostMarv Martin
# Taken from Code library last updated: 2007-01-05
# Released under http://creativecommons.org/licenses/by-sa/2.5/
# Released under http://creativecommons.org/licenses/by-sa/2.5/
if(strlen(base64_decode($s1)) > strlen(base64_decode($s2)))
if(strlen(base64_decode($s1)) > strlen(base64_decode($s2)))
{
{
$s2 = base64_encode(str_pad(base64_decode($s2),strlen(base64_decode($s1)),base64_decode($s2),STR_PAD_RIGHT));
$s2 = base64_encode(
str_pad(base64_decode($s2),
strlen(base64_decode($s1)),
base64_decode($s2),
STR_PAD_RIGHT
)
);
}
}
return base64_encode(base64_decode($s1) ^ base64_decode($s2));
return base64_encode(base64_decode($s1) ^ base64_decode($s2));
}
}
?></nowiki></pre></code></div>
?></php></div>

Revision as of 07:46, 22 February 2008

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/

if(strlen(base64_decode($s1)) > strlen(base64_decode($s2))) { $s2 = base64_encode( str_pad(base64_decode($s2), strlen(base64_decode($s1)), base64_decode($s2), STR_PAD_RIGHT ) ); } return base64_encode(base64_decode($s1) ^ base64_decode($s2)); }

?></php>