File tree Expand file tree Collapse file tree
src/Illuminate/Encryption Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,21 +16,21 @@ class Encrypter {
1616 *
1717 * @var string
1818 */
19- protected $ cipher = ' rijndael-256 ' ;
19+ protected $ cipher = MCRYPT_RIJNDAEL_128 ;
2020
2121 /**
2222 * The mode used for encryption.
2323 *
2424 * @var string
2525 */
26- protected $ mode = ' cbc ' ;
26+ protected $ mode = MCRYPT_MODE_CBC ;
2727
2828 /**
2929 * The block size of the cipher.
3030 *
3131 * @var int
3232 */
33- protected $ block = 32 ;
33+ protected $ block = 16 ;
3434
3535 /**
3636 * Create a new encrypter instance.
@@ -257,6 +257,7 @@ public function setKey($key)
257257 public function setCipher ($ cipher )
258258 {
259259 $ this ->cipher = $ cipher ;
260+ $ this ->updateBlockSize ();
260261 }
261262
262263 /**
@@ -268,6 +269,12 @@ public function setCipher($cipher)
268269 public function setMode ($ mode )
269270 {
270271 $ this ->mode = $ mode ;
272+ $ this ->updateBlockSize ();
273+ }
274+
275+ private function updateBlockSize ()
276+ {
277+ $ this ->block = mcrypt_get_iv_size ($ this ->cipher , $ this ->mode );
271278 }
272279
273280}
Original file line number Diff line number Diff line change @@ -12,6 +12,14 @@ public function testEncryption()
1212 $ this ->assertTrue ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ' == $ e ->decrypt ($ encrypted ));
1313 }
1414
15+ public function testEncryptionWithCustomCipher ()
16+ {
17+ $ e = $ this ->getEncrypter ();
18+ $ e ->setCipher (MCRYPT_RIJNDAEL_256 );
19+ $ this ->assertFalse ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ' == $ e ->encrypt ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ' ));
20+ $ encrypted = $ e ->encrypt ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ' );
21+ $ this ->assertTrue ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ' == $ e ->decrypt ($ encrypted ));
22+ }
1523
1624 /**
1725 * @expectedException Illuminate\Encryption\DecryptException
You can’t perform that action at this time.
0 commit comments