public
Last active — forked from bxt/gist:846141

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
#!/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";
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.