Skip to content

Instantly share code, notes, and snippets.

@ctkqiang
Created May 3, 2020 19:13
Show Gist options
  • Save ctkqiang/d6492ea9a21a5c8793d30532d9bfa741 to your computer and use it in GitHub Desktop.
Save ctkqiang/d6492ea9a21a5c8793d30532d9bfa741 to your computer and use it in GitHub Desktop.
Hey guys am i doing it right or wrong? My intention is to decode hashes I just encoded of an image. How do I decode ? My code Need review ::
<?php
// My intention is to decodeencrypted image hashes
// and export back to File(image.extension)
echo "Decrypt {string} or {file}? [input: \"str\" || \"bin\", type \"exit()\" for quit the programme]";
$__userInputOption = rtrim(fgets(STDIN));
if ($__userInputOption == "str"){
echo "Please enter {string} you want to decode: \n";
$_input = rtrim(fgets(STDIN));
$_encodedString = base64_decode($_input);
echo "Encoded String: ".$_input."\n";
echo "Decoded String: ".$_encodedString;
} else if ($__userInputOption == "exit()") {
exit();
} else if ($__userInputOption == "bin") {
echo "Please enter {binary} you want to decode: \n";
$__userInputBinary = rtrim(fgets(STDIN));
$__post_decryption = file_get_contents($__userInputBinary);
$__decryptedData = base64_decode($__post_decryption);
// echo "Original binary".$__userInputBinary;
echo "Decrypted binary hashes: ".$__decryptedData;
} else {
printf("Please enter a valid input");
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment