PHP中的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);

我对加密了解不多,但据我所知,DES不是推荐的加密标准:http://en.wikipedia.org/wiki/Data_Encryption_Standard

如果您追求更安全的东西,请查看这里的问题,其中包括工作的加密/解密函数

最新更新