Let us begin with the true PHP function:

1. function XOREncryption($InputString, $KeyPhrase){


3.     $KeyPhraseLength = strlen($KeyPhrase)


5.     // Loop trough input string

6.     for ($i = 0 $i //SALT

$salt = ‘my_special_phrase’


$crypted = base64_encode(XOREncryption(‘my string’, $salt))

echo “Encrypted: ” . $crypted . “

 The variable ‘ $salt ‘ plays a important function right here.  It is primarily the ‘key’ to your encrypted string. The salt price will constantly produce the same values when the similar arithmetic are applied to it.  It gives the frequent wanted to deliver randomness.  This goes to say that if an individual makes use of the salt that was made use of to generate the encryption and applies the very same arithmetic they can undo or reverse the encrypted string back into the initial string text.

In get to decrypt an encrypted string that was generated by utilizing this functionality use the invoccation code under:


$salt = ‘my_exclusive_phrase’


$decrypted  = XOREncryption(base64_decode($crypted), $salt)

echo “Decrypted: ” . $decrypted

As extensive as I use the exact same salt I can reverse an encrypted string that was encrypted with this function.