在PHP GET方法中从查询参数解密基本身份验证令牌
我想解密使用基本身份验证加密的用户名和密码 在我的客户端应用程序中,我有一个文件列表。如果用户想要下载,他们将单击指向带有param在PHP GET方法中从查询参数解密基本身份验证令牌,php,basic-authentication,php-7,php-7.2,auth-token,Php,Basic Authentication,Php 7,Php 7.2,Auth Token,我想解密使用基本身份验证加密的用户名和密码 在我的客户端应用程序中,我有一个文件列表。如果用户想要下载,他们将单击指向带有paramid(即fileId)和token的PHP文件的锚定链接 我有一个客户端锚标签,比如 <a href="http://localhost:8080/management/download.php?id=1&token=YmFsYTphYWFhYWFhYWFh"> download </a> 文件:下载.php $fileId
id
(即fileId
)和token
的PHP文件的锚定链接
我有一个客户端锚标签,比如
<a href="http://localhost:8080/management/download.php?id=1&token=YmFsYTphYWFhYWFhYWFh">
download
</a>
文件:下载.php
$fileId = $_GET['id'];
$token = $_GET['token'];
$filePath = getFileById($fileId);
if (file_exists($filePath)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($filePath).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($filePath));
readfile($filePath);
exit;
}
我试图从默认的$\u服务器['PHP\u AUTH\u USER']
获取用户名和密码,但未能获取信息
请帮助我如何从令牌中解密用户名和密码。在PHP中使用以:
分隔的用户名和密码
<?php
$decoded = base64_decode($_GET['token']);
list($username,$password) = explode(":",$decoded);
echo $username," ",$password;
是的,这是一种非常非常不安全的方式,但总比没有好,这就是想法。在API调用中,我们使用头身份验证。我对您的努力投了赞成票,测试后,我会将您的答案标记为正确。
<?php
$decoded = base64_decode($_GET['token']);
list($username,$password) = explode(":",$decoded);
echo $username," ",$password;