Created
February 27, 2011 12:27
-
-
Save bxt/846141 to your computer and use it in GitHub Desktop.
PHP-Script to calculate various hash sums
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?php | |
$silent=false; | |
if($argc>2&&$argv[2]=="-") { | |
$silent=true; | |
} else { | |
fputs(STDOUT,"Enter text:"); | |
} | |
$input = trim(fgets(STDIN)); | |
$algo=""; | |
if($argc>1&&$argv[1]=="--md5") { | |
$algo="1"; | |
} elseif ($argc>1&&$argv[1]=="--sha1") { | |
$algo="2"; | |
} elseif ($argc>1&&$argv[1]=="--sha512") { | |
$algo="3"; | |
} | |
if($algo=="") { | |
echo "md5 : "; | |
echo md5($input); | |
echo "\n"; | |
echo "sha1 : "; | |
echo sha1($input); | |
echo "\n"; | |
echo "sha512 : "; | |
echo hash("sha512",$input); | |
echo "\n"; | |
} elseif ($algo=="1") { | |
echo md5($input); | |
} elseif ($algo=="2") { | |
echo sha1($input); | |
} elseif ($algo=="3") { | |
echo hash("sha512",$input); | |
} | |
if(!$silent&&$algo!="") { | |
echo "\n"; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment