使用PHP加密

时间:2012-09-02 09:12:35

标签: php string encryption key encode

我想加密整个PHP文件的内容。 我找到了这个,四处寻找:

$key = 'password to (en/de)crypt';  
$string = ' string to be encrypted '; // note the spaces

要加密:

$encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), 
                           $string, MCRYPT_MODE_CBC, md5(md5($key))));

我想使用完全相同的方法,但我不知道如何。
我是否需要删除文件的标签?

1 个答案:

答案 0 :(得分:1)

只需使用file_get_contents()读取文件,将其存储在$string中,对其进行加密,然后使用file_put_contents()再次将其写入磁盘。