The following three custom functions can be used in PHP applications to help make development easier and faster.
That's it! Now you can use these functions to quickly validate URLs, encrypt strings, and decrypt strings.
PHP:
<?php
// Returns TRUE if the given string is a valid URL
function isValidUrl($url) {
return filter_var($url, FILTER_VALIDATE_URL);
}
// Encrypts a string using a given key
function encryptString($string, $key) {
return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $string, MCRYPT_MODE_ECB));
}
// Decrypts a string using a given key
function decryptString($string, $key) {
return mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($string), MCRYPT_MODE_ECB);
}
?>
That's it! Now you can use these functions to quickly validate URLs, encrypt strings, and decrypt strings.