DES Encryption and Decryption in PHP

492 views Asked by At

Please help. How do I make an array in encrypt and decrypt?

<?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

There are 1 answers

0
Bendy On

I don't know much on encryption but from what I understand, DES isn't a recommended encryption standard:http://en.wikipedia.org/wiki/Data_Encryption_Standard

If you're after something more secure, have a look at the question here that includes a encryption/decryption functions that work