src/Security/Crypter.php
public function encrypt($plaintext, $key)
	{
		// Set up encryption parameters.
		$inputData = cryptoHelpers::convertStringToByteArray($plaintext);
		$keyAsNumbers = cryptoHelpers::toNumbers(bin2hex($key));
		$keyLength = count($keyAsNumbers);
		$iv = cryptoHelpers::generateSharedKey(16);

		$encrypted = AES::encrypt(
			$inputData,
			AES::modeOfOperation_CBC,
			$keyAsNumbers,
			$keyLength,
			$iv
		);

		$retVal = $encrypted['originalsize'] . self::SEPARATOR_CRYPTO_PARTS
			. cryptoHelpers::toHex($iv) . self::SEPARATOR_CRYPTO_PARTS
			. cryptoHelpers::toHex($encrypted['cipher']);

		return self::IDENTIFIER . self::SEPARATOR_ALGORITHM . $retVal;
	}
public function encrypt($plaintext, $key)
	{
		// Set up encryption parameters.
		$inputData = cryptoHelpers::convertStringToByteArray($plaintext);
		$keyAsNumbers = cryptoHelpers::toNumbers(bin2hex($key));
		$keyLength = count($keyAsNumbers);
		$iv = cryptoHelpers::generateSharedKey(16);

		$encrypted = AES::encrypt(
			$inputData,
			AES::modeOfOperation_CBC,
			$keyAsNumbers,
			$keyLength,
			$iv
		);

		$retVal = $encrypted['originalsize'] . self::SEPARATOR_CRYPTO_PARTS
			. cryptoHelpers::toHex($iv) . self::SEPARATOR_CRYPTO_PARTS
			. cryptoHelpers::toHex($encrypted['cipher']);

		return self::IDENTIFIER . self::SEPARATOR_ALGORITHM . $retVal;
	}
public function encrypt ( $ plaintext , $ key ) { // Set up encryption parameters. $ inputData = cryptoHelpers :: convertStringToByteArray ( $ plaintext ) ; $ keyAsNumbers = cryptoHelpers :: toNumbers ( bin2hex ( $ key ) ) ; $ keyLength = count ( $ keyAsNumbers ) ; $ iv = cryptoHelpers :: generateSharedKey ( 16 ) ; $ encrypted = AES :: encrypt ( $ inputData , AES :: modeOfOperation_CBC , $ keyAsNumbers , $ keyLength , $ iv ) ; $ retVal = $ encrypted [ 'originalsize' ] . self :: SEPARATOR_CRYPTO_PARTS . cryptoHelpers :: toHex ( $ iv ) . self :: SEPARATOR_CRYPTO_PARTS . cryptoHelpers :: toHex ( $ encrypted [ 'cipher' ] ) ; return self :: IDENTIFIER . self :: SEPARATOR_ALGORITHM . $ retVal ; }
encrypts the given plain text with a key

@param string $plaintext
@param string $key

@return string
encrypts the given plain text with a key