private function encrypt($text, $corpId)
    {
        try {
            $key = $this->getAESKey();
            $random = $this->getRandomStr();
            $text = $this->encode($random.pack('N', strlen($text)).$text.$corpId);

            $iv = substr($key, 0, 16);

            $encrypted = openssl_encrypt($text, 'aes-256-cbc', $key, OPENSSL_RAW_DATA | OPENSSL_NO_PADDING, $iv);

            return base64_encode($encrypted);
        } catch (BaseException $e) {
            throw new EncryptionException($e->getMessage(), EncryptionException::ERROR_ENCRYPT_AES);
        }
    }
private function encrypt($text, $corpId)
    {
        try {
            $key = $this->getAESKey();
            $random = $this->getRandomStr();
            $text = $this->encode($random.pack('N', strlen($text)).$text.$corpId);

            $iv = substr($key, 0, 16);

            $encrypted = openssl_encrypt($text, 'aes-256-cbc', $key, OPENSSL_RAW_DATA | OPENSSL_NO_PADDING, $iv);

            return base64_encode($encrypted);
        } catch (BaseException $e) {
            throw new EncryptionException($e->getMessage(), EncryptionException::ERROR_ENCRYPT_AES);
        }
    }
private function encrypt ( $ text , $ corpId ) { try { $ key = $ this -> getAESKey ( ) ; $ random = $ this -> getRandomStr ( ) ; $ text = $ this -> encode ( $ random . pack ( 'N' , strlen ( $ text ) ) . $ text . $ corpId ) ; $ iv = substr ( $ key , 0 , 16 ) ; $ encrypted = openssl_encrypt ( $ text , 'aes-256-cbc' , $ key , OPENSSL_RAW_DATA | OPENSSL_NO_PADDING , $ iv ) ; return base64_encode ( $ encrypted ) ; } catch ( BaseException $ e ) { throw new EncryptionException ( $ e -> getMessage ( ) , EncryptionException :: ERROR_ENCRYPT_AES ) ; } }
Encrypt string.

@param string $text
@param string $corpId

@throws EncryptionException

@return string
Encrypt string .