Skip to content

Commit

Permalink
added base64_decode && base64_encode support
Browse files Browse the repository at this point in the history
  • Loading branch information
bariseser committed Jul 31, 2019
1 parent d2f6b95 commit 183968a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Cryptographers.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Cryptographers
/**
* @var string
*/
public static $chipper = "aes-256-ctr";
public static $chipper = "aes-256-cbc";

/**
* @var string
Expand All @@ -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));
}

/**
Expand All @@ -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]);
}

/**
Expand Down

0 comments on commit 183968a

Please sign in to comment.