寻找简单的PHP多路加密方法 [英] looking for simple PHP multi way encryption method
问题描述
我已经看了一下crypt()(但是只有一个 - 方式)和Mcrypt,GnuPG,但我不满意他们。我认为他们是为了我的简单问题复杂。我该用什么我不需要IV形状或超级安全算法。有没有什么基本的PHP功能,我还不知道?
我只需要隐藏像这样的用户的图像:
ImageJPEG(ImageCreateFromJPEG解码($ _ REQUEST ['encryptedImage'],'secret key')));
/ p>
<?php
define('SECRET',md5('Some secret key'));
函数加密($ value){
$ iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256,MCRYPT_MODE_ECB);
$ iv = mcrypt_create_iv($ iv_size,MCRYPT_RAND);
return mcrypt_encrypt(MCRYPT_RIJNDAEL_256,SECRET,$ value,MCRYPT_MODE_ECB,$ iv);
}
函数解密($ value){
$ iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256,MCRYPT_MODE_ECB);
$ iv = mcrypt_create_iv($ iv_size,MCRYPT_RAND);
return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256,SECRET,$ value,MCRYPT_MODE_ECB,$ iv));
}
?>
I need to decrypt encrypted POST value strings with the aid of a secret static key.
I have had a look into crypt() (but it's only one-way) and Mcrypt, GnuPG,... but I'm not happy with them. I think they are to complex for my simple issue. What should I use? I don't need IV shapes or super safe algorithms. Is there any basic PHP function, that I don't know yet?
I just need to hide image pathes from users like that: ImageJPEG(ImageCreateFromJPEG( decode($_REQUEST['encryptedImage'],'secret Key') ));
Cant get simpler then this:
<?php
define('SECRET',md5('Some secret key'));
function encrypt($value){
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
return mcrypt_encrypt(MCRYPT_RIJNDAEL_256, SECRET, $value, MCRYPT_MODE_ECB, $iv);
}
function decrypt($value){
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, SECRET, $value, MCRYPT_MODE_ECB, $iv));
}
?>
这篇关于寻找简单的PHP多路加密方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!