2013-09-21 15:03:59 +00:00
|
|
|
<?php
|
|
|
|
|
2015-09-25 15:42:00 +00:00
|
|
|
class m_crypto {
|
2013-09-21 15:03:59 +00:00
|
|
|
|
2015-09-25 15:42:00 +00:00
|
|
|
function encrypt($sValue, $sSecretKey) {
|
|
|
|
return rtrim(
|
2017-10-06 21:42:39 +00:00
|
|
|
base64_encode(
|
|
|
|
mcrypt_encrypt(
|
|
|
|
MCRYPT_RIJNDAEL_256, $sSecretKey, $sValue, MCRYPT_MODE_ECB, mcrypt_create_iv(
|
|
|
|
mcrypt_get_iv_size(
|
|
|
|
MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB
|
|
|
|
), MCRYPT_RAND
|
|
|
|
)
|
|
|
|
)
|
|
|
|
), "\0"
|
2015-09-25 15:42:00 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function decrypt($sValue, $sSecretKey) {
|
|
|
|
return rtrim(
|
2017-10-06 21:42:39 +00:00
|
|
|
mcrypt_decrypt(
|
|
|
|
MCRYPT_RIJNDAEL_256, $sSecretKey, base64_decode($sValue), MCRYPT_MODE_ECB, mcrypt_create_iv(
|
|
|
|
mcrypt_get_iv_size(
|
|
|
|
MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB
|
|
|
|
), MCRYPT_RAND
|
|
|
|
)
|
|
|
|
), "\0"
|
2015-09-25 15:42:00 +00:00
|
|
|
);
|
|
|
|
}
|
2013-09-21 15:03:59 +00:00
|
|
|
|
|
|
|
}
|