php - How to check if md5 is empty? -
i using md5 hash store password database. know empty string have md5 hash.
question how can check if user give me empty string?i mean: user can give "" , can give me space " " how differentiate between them. yes can utilize trim normal php code , check if empty or not. how can check if md5?
why don't check if string empty first before encrypt it?
anyway piece of code trick
<?php $md5 = 'd67c5cbf5b01c9f91932e3b8def5e5f8'; $flag = check_valid_md5_string($md5); if ($flag){ // flag true means string valid md5 encrypation echo 'valid md5 string'; }else{ echo 'invalid md5 string or empty string'; } //this function check string function check_valid_md5_string($md5=''){ if(empty($md5)) homecoming false; homecoming preg_match('/^[a-f0-9]{32}$/', $md5); } ?> reference
php hash md5
No comments:
Post a Comment