|
@@ -12,11 +12,13 @@
|
|
|
$methods = Encryption::methods();
|
|
|
do{
|
|
|
$method = $methods[random_int(0, count($methods) - 1)];
|
|
|
- $this->encryption = Encryption::from($method);
|
|
|
- $ivlen = $this->encryption->iv_len();
|
|
|
- $this->password = openssl_random_pseudo_bytes($ivlen);
|
|
|
- $this->iv = openssl_random_pseudo_bytes($ivlen);
|
|
|
- $this->data = $this->encryption->encrypt($data, $this->password, $this->iv);
|
|
|
+ try{
|
|
|
+ $this->encryption = Encryption::from($method);
|
|
|
+ $ivlen = $this->encryption->iv_len();
|
|
|
+ $this->password = openssl_random_pseudo_bytes($ivlen);
|
|
|
+ $this->iv = openssl_random_pseudo_bytes($ivlen);
|
|
|
+ $this->data = $this->encryption->encrypt($data, $this->password, $this->iv);
|
|
|
+ }catch(Exception $e){}
|
|
|
if(++$tries == count($methods)){
|
|
|
throw new \Exception("Too many failed attempts to encrypt data");
|
|
|
}
|