src/RNCryptor/Encryptor.php
public function encrypt($plaintext, $password, $version = Cryptor::DEFAULT_SCHEMA_VERSION, $base64Encode = true)
    {
        $this->configure($version);

        $components = $this->makeComponents($version);
        $components->headers->encSalt = $this->makeSalt();
        $components->headers->hmacSalt = $this->makeSalt();
        $components->headers->iv = $this->makeIv($this->config->ivLength);

        $encKey = $this->makeKey($components->headers->encSalt, $password);
        $hmacKey = $this->makeKey($components->headers->hmacSalt, $password);

        return $this->encryptFromComponents($plaintext, $components, $encKey, $hmacKey, $base64Encode);
    }
public function encrypt($plaintext, $password, $version = Cryptor::DEFAULT_SCHEMA_VERSION, $base64Encode = true)
    {
        $this->configure($version);

        $components = $this->makeComponents($version);
        $components->headers->encSalt = $this->makeSalt();
        $components->headers->hmacSalt = $this->makeSalt();
        $components->headers->iv = $this->makeIv($this->config->ivLength);

        $encKey = $this->makeKey($components->headers->encSalt, $password);
        $hmacKey = $this->makeKey($components->headers->hmacSalt, $password);

        return $this->encryptFromComponents($plaintext, $components, $encKey, $hmacKey, $base64Encode);
    }
public function encrypt ( $ plaintext , $ password , $ version = Cryptor :: DEFAULT_SCHEMA_VERSION , $ base64Encode = true ) { $ this -> configure ( $ version ) ; $ components = $ this -> makeComponents ( $ version ) ; $ components -> headers -> encSalt = $ this -> makeSalt ( ) ; $ components -> headers -> hmacSalt = $ this -> makeSalt ( ) ; $ components -> headers -> iv = $ this -> makeIv ( $ this -> config -> ivLength ) ; $ encKey = $ this -> makeKey ( $ components -> headers -> encSalt , $ password ) ; $ hmacKey = $ this -> makeKey ( $ components -> headers -> hmacSalt , $ password ) ; return $ this -> encryptFromComponents ( $ plaintext , $ components , $ encKey , $ hmacKey , $ base64Encode ) ; }
Encrypt plaintext using RNCryptor's algorithm

@param string $plaintext Text to be encrypted
@param string $password Password to use
@param int $version (Optional) RNCryptor schema version to use.
@throws \Exception If the provided version (if any) is unsupported
@return string Encrypted, Base64-encoded string
Encrypt plaintext using RNCryptor s algorithm