From 183968af7468e99824077713ac5890df6050cf29 Mon Sep 17 00:00:00 2001 From: baris eser Date: Wed, 31 Jul 2019 16:36:03 +0300 Subject: [PATCH] added base64_decode && base64_encode support --- src/Cryptographers.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Cryptographers.php b/src/Cryptographers.php index da8d045..241d8af 100644 --- a/src/Cryptographers.php +++ b/src/Cryptographers.php @@ -13,7 +13,7 @@ class Cryptographers /** * @var string */ - public static $chipper = "aes-256-ctr"; + public static $chipper = "aes-256-cbc"; /** * @var string @@ -38,7 +38,7 @@ public static function encrypt(string $data): string } $iv = self::getRandomByte(); - return $iv . "." . openssl_encrypt($data, self::$chipper, self::getSalt(), $options = 0, $iv); + return $iv . "." . base64_encode(openssl_encrypt($data, self::$chipper, self::getSalt(), $options = 0, $iv)); } /** @@ -51,7 +51,7 @@ public static function decrypt(string $data) :string throw new \InvalidArgumentException("Data cannot be empty"); } - return openssl_decrypt(self::getEncryptedData($data)[1], self::$chipper, self::getSalt(), $options = 0, self::getEncryptedData($data)[0]); + return openssl_decrypt(base64_decode(self::getEncryptedData($data)[1]), self::$chipper, self::getSalt(), $options = 0, self::getEncryptedData($data)[0]); } /**