<?php
/**
* Encryption of simple symmetric encryption algorithm
* @param string $string strings that need to be encrypted
* @param String $skey Encryption Eky
* @author Anyon Zou <[email protected]>
* @date 2013-08-13 19:30
* @update 2014-10-10 10:10
* @return String
*/
Class Eddate {
Public Function encode ($string = ', $skey = ' cxphp ') {
$STRARR = Str_split (Base64_encode ($string));
$strCount = count ($STRARR);
foreach (Str_split ($skey) as $key = $value)
$key < $strCount && $strArr [$key].= $value;
return Str_replace (Array (' = ', ' + ', '/'), Array (' o0o0o ', ' o000o ', ' oo00o '), join (', $STRARR));
}
/**
* Decryption of simple symmetric encryption algorithm
* @param string $string A string to decrypt
* @param String $skey Decrypt key
* @author Anyon Zou <[email protected]>
* @date 2013-08-13 19:30
* @update 2014-10-10 10:10
* @return String
*/
Public Function decode ($string = ', $skey = ' cxphp ') {
$STRARR = Str_split (Str_replace (' o0o0o ', ' o000o ', ' oo00o '), array (' = ', ' + ', '/'), $string), 2);
$strCount = count ($STRARR);
foreach (Str_split ($skey) as $key = $value)
$key <= $strCount && isset ($STRARR [$key]) && $STRARR [$key][1] = = = $value && $strArr [$key] = $s trarr[$key][0];
Return Base64_decode (Join (', $STRARR));
}
}
PHP Data encryption