Support Forums

Full Version: [Function] XOR Encryption/Decryption with a Key
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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;
}
?>