public static function encrypt($plaintext, $password, $cost = 0, $cipher = MCRYPT_RIJNDAEL_128, $mode = MCRYPT_MODE_CBC, $algo = 'sha256')
{
// Pad the input string to a multiple of block size
$padded = Pkcs7::pad($plaintext, \mcrypt_get_block_size($cipher, $mode));
// Generate IV of appropriate size
$iv = Random::bytes(\mcrypt_get_iv_size($cipher, $mode));
// Derive key from password
$key = self::key($password, $iv, $cost, $cipher, $mode, $algo);
// Encrypt the plaintext
$message = \mcrypt_encrypt($cipher, $key, $padded, $mode, $iv);
// Create the cypher text prefix (iv + checksum)
$prefix = $iv . self::checksum($message, $iv, $key, $cipher, $mode, $algo);
// Return prefix + cyphertext
return $prefix . $message;
}