This repository has been archived on 2022-12-28. You can view files and clone it, but cannot push or open issues or pull requests.
apiOld/old/crypt/decrypt/api.php
2021-01-01 15:48:55 +08:00

31 lines
1.2 KiB
PHP

<?php
header("Content-type:application/json");
$db=mysqli_connect("localhost","ghinkapi","ghink2014","ghinkapi");
mysqli_query($db,"set names utf8");
if($_GET['type']==""){
$result_md5=mysqli_fetch_array(mysqli_query($db,"SELECT * FROM `crypt_md5` WHERE `encrypted`='".$_GET['text']."'"));
$result_sha1=mysqli_fetch_array(mysqli_query($db,"SELECT * FROM `crypt_sha1` WHERE `encrypted`='".$_GET['text']."'"));
if(empty($result_md5) and !empty($result_sha1)){
echo $result_sha1['unencrypted'];
}elseif(!empty($result_md5) and empty($result_sha1)){
echo $result_md5['unencrypted'];
}else{
echo '["md5":"'.$result_md5['unencrypted'].'","sha1":"'.$result_sha1['unencrypted'].'"]';
}
}elseif($_GET['type']=="md5"){
$result_md5=mysqli_fetch_array(mysqli_query($db,"SELECT * FROM `crypt_md5` WHERE `encrypted`='".$_GET['text']."'"));
if(empty($result_md5)){
echo '{"error":"10003"}';
}else{
echo $result_md5['unencrypted'];
}
}elseif($_GET['type']=="sha1"){
$result_sha1=mysqli_fetch_array(mysqli_query($db,"SELECT * FROM `crypt_sha1` WHERE `encrypted`='".$_GET['text']."'"));
if(empty($result_sha1)){
echo '{"error":"10003"}';
}else{
echo $result_sha1['unencrypted'];
}
}else{
echo '{"error":"10004"}';
}