Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Function] XOR Encryption/Decryption with a Key
#1
Another function coded by me to encrypt/decrypt a string using a key.

PHP Code:
<?php
// Example Usage: echo xorencrypt('examplestring,'examplekey');
function XOREncryption($InputString$KeyPhrase){
$KeyPhraseLength strlen($KeyPhrase);
for (
$i 0$i strlen($InputString); $i++){
$rPos $i $KeyPhraseLength;
$r ord($InputString[$i]) ^ ord($KeyPhrase[$rPos]);
$InputString[$i] = chr($r);
}
return 
$InputString;
}
function 
xorencrypt($InputString$KeyPhrase){
    
$InputString XOREncryption($InputString$KeyPhrase);
    
$InputString base64_encode($InputString);
    return 
$InputString;
}
function 
xordecrypt($InputString$KeyPhrase){
    
$InputString base64_decode($InputString);
    
$InputString XOREncryption($InputString$KeyPhrase);
    return 
$InputString;
}
?>
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Noob's doubt on echo function in php mandi 5 1,466 12-09-2010, 06:00 AM
Last Post: Orgy
  [Function] Force download of a file OX!DE 1 845 02-25-2010, 07:28 PM
Last Post: h1r0n
  [Function] Test HTTP/Socks 4/Socks 5 Proxy OX!DE 0 2,543 02-21-2010, 07:10 PM
Last Post: OX!DE
  Email PHP function and connecting it to a form Tasemu 3 2,101 10-09-2009, 05:22 AM
Last Post: Tasemu

Forum Jump:


Users browsing this thread: 1 Guest(s)