oxencryptor.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class oxEncryptor
00007 {
00008 
00017     public function encrypt($sString, $sKey)
00018     {
00019         $sString = "ox{$sString}id";
00020 
00021         $sKey = $this->_formKey($sKey, $sString);
00022 
00023         $sString = $sString ^ $sKey;
00024         $sString = base64_encode($sString);
00025         $sString = str_replace("=", "!", $sString);
00026 
00027         return "ox_$sString";
00028     }
00029 
00038     protected function _formKey($sKey, $sString)
00039     {
00040         $sKey = '_' . $sKey;
00041         $iKeyLength = (strlen($sString) / strlen($sKey)) + 5;
00042 
00043         return str_repeat($sKey, $iKeyLength);
00044     }
00045 }