PHP加密的登录凭据访问API [英] PHP-Encrypting login Credentials Accessing API

查看:165
本文介绍了PHP加密的登录凭据访问API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图调用API收获。但是,为了做到这一点的用户名和密码已被放在PHP文件。现在,我有安全问题,我不想直接把我的登录凭证在一个文件中。我看了一下散列机制,例如SHA1,MD5。请问这是否适用于我的情况?因为大多数我期待现在的例子是基于验证的登录凭据。在这里,我需要一种方法来隐藏我的登录凭据,所以它不是公开暴露出来。请提出一个方法去了解这一点。

  $ USER = //实际的用户名;
$密码= //实际的密码
$ harvest_user = $用户; //收获用户名,通常是电子邮件地址
$ harvest_pass = $密码; //收获密码
$ harvest_account = $帐户;require_once'HarvestAPI.php';spl_autoload_register(阵列('HarvestAPI','自动加载'));$ harvestAPI =新HarvestAPI();
$ harvestAPI-> SETUSER($ harvest_user);
$ harvestAPI-> setPassword($ harvest_pass);
$ harvestAPI-> setAccount($ harvest_account);$结果= $ harvestAPI-> getUsers();
//如果收获成功返回
如果($ result-> code == 200){
  $人= $ result->数据;
}
其他{
回声不成功;
}
?>


解决方案

您可以使用的MD5()方法。

只是加密在数据库或别的地方你存储的登录信息注册和存储IST后的密码。

在登陆只是加密类型密码的支票如果同一像在你的数据库中。

没有人可以从数据库中的密码,因为的MD5()方法不
可逆的。

加密这样的: $ pw2store = MD5($密码);

,或使用具有加密的一个密码: $密码= MD5($密码);

希望我能帮上忙。

I am trying to call the Harvest API. But,in order to do that the username and password has to be put in the PHP file. Now, I have security concerns, I don't want to directly put my login credentials in a file. I have read about hashing mechanisms like SHA1, md5. Would that be applicable to my situation? Because most of the examples I am looking right now are based on verifying login credentials. Here, I need a way to hide my login credentials so it is not exposed publicly. Kindly suggest a way to go about this.

$user= //Actual username;
$password= //Actual Password
$harvest_user = $user; // Harvest username, usually an email address
$harvest_pass = $password; //  Harvest password
$harvest_account = $account;

require_once 'HarvestAPI.php';

spl_autoload_register(array('HarvestAPI', 'autoload') );

$harvestAPI = new HarvestAPI();
$harvestAPI->setUser($harvest_user);
$harvestAPI->setPassword($harvest_pass);
$harvestAPI->setAccount($harvest_account);

$result = $harvestAPI->getUsers();
// If Harvest returns successful
if ($result->code == 200) {
  $people = $result->data;
}
else{
echo "Not Successful";
}
?>

解决方案

You can use the md5() Method.

Just encrypt the password after the registration and store ist in a database or where else you are storing the login information.

At the login just encrypt the typed password an check if its the same like the one in your database.

Nobody can get the password from the database because the md5() Method isn't reversible.

Encrypt like that: $pw2store = md5($password);

Or replace the password with the encrypted one: $password = md5($password);

Hoped I could help.

这篇关于PHP加密的登录凭据访问API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆