src/Handlers/Security/Crypter.php
public function encrypt($data, $key) {
      $this->validateData($data);
      $this->validateKey($key);

      $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length(self::CIPHER_METHOD));

      $encrypted = openssl_encrypt($data, self::CIPHER_METHOD, $key, 0, $iv);
      $encoded = base64_encode($encrypted . self::ENCRYPTED_IV_SEPERATOR . $iv);

      return new Encrypted($encoded);
    }
public function encrypt($data, $key) {
      $this->validateData($data);
      $this->validateKey($key);

      $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length(self::CIPHER_METHOD));

      $encrypted = openssl_encrypt($data, self::CIPHER_METHOD, $key, 0, $iv);
      $encoded = base64_encode($encrypted . self::ENCRYPTED_IV_SEPERATOR . $iv);

      return new Encrypted($encoded);
    }
public function encrypt ( $ data , $ key ) { $ this -> validateData ( $ data ) ; $ this -> validateKey ( $ key ) ; $ iv = openssl_random_pseudo_bytes ( openssl_cipher_iv_length ( self :: CIPHER_METHOD ) ) ; $ encrypted = openssl_encrypt ( $ data , self :: CIPHER_METHOD , $ key , 0 , $ iv ) ; $ encoded = base64_encode ( $ encrypted . self :: ENCRYPTED_IV_SEPERATOR . $ iv ) ; return new Encrypted ( $ encoded ) ; }
Encrypt data by key

@param string $data
@param string $key
@return Encrypted
Encrypt data by key