PHP中的DES加密和解密

时间:2015-06-08 15:00:42

标签: php arrays des

请帮忙。如何在加密和解密中创建数组?

<?php
    class DES{

        function encrypt($plainText, $cipherKey){
            //plainText
            $result = $this->toBiner($plainText);
            $result = $this->InitialPermutation($result);
            //key
            $key = $this->toBiner($cipherKey);
            $key = $this->kompresBit($key);
            $arrLeftShift = $this->LeftShift($key);
            //final
            $result = $this->keyExpansion($result, $arrLeftShift);
            return $result;
        }

        function decrypt($encryptedText, $cipherKey){
            $key = $this->toBiner($cipherKey);
            $key = $this->kompresBit($key);
            $arrLeftShift = $this->LeftShift($key);

            $result = $this->reverseKeyExpansion($encryptedText, $arrLeftShift);
            $result = $this->revInitialPermutation($result);

1 个答案:

答案 0 :(得分:1)

我对加密知之甚少,但根据我的理解,DES不是推荐的加密标准:http://en.wikipedia.org/wiki/Data_Encryption_Standard

如果您正在寻找更安全的内容,请查看包含加密/解密功能的问题here