如何在 php 中隐藏/保护密码详细信息? [英] How to hide/protect password details in php?

查看:32
本文介绍了如何在 php 中隐藏/保护密码详细信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个网站,我试图在其中创建一个表单,该表单将用户输入发送到我的谷歌文档/驱动器中的谷歌电子表格...我发现了一个 Github 项目,可以让人们对 php 进行编码...它包括脚本所需的其他 2 个 php 文件.代码如下:

I'm making a website in which I'm trying to create a form that will send the user-input to a google spreadsheet in my google docs/drive... I found a Github project that lets people code the php... It includes 2 other php files which are needed for the script. The code is as follows:

我的问题是,如何在 $u =/$p = 下的脚本中隐藏我的密码?查看代码的任何人都可以看到我的密码..我该如何防止?

My question is, how can I hide my password from this script under $u = / $p = ?? Anyone viewing the code can see my password.. how can I prevent that?

脚本来源的链接是:http://www.farinspace.com/saving-form-data-to-google-spreadsheets/

<?php

// Zend library include path
set_include_path(get_include_path() . PATH_SEPARATOR . "$_SERVER[DOCUMENT_ROOT]/ZendGdata-1.8.1/library");

include_once("Google_Spreadsheet.php");

$u = "username@gmail.com";
$p = "password";

$ss = new Google_Spreadsheet($u,$p);
$ss->useSpreadsheet("My Spreadsheet");
$ss->useWorksheet("wks2");

// important:
// adding a leading alpha char prevents errors, there are issues 
// when trying to lookup an identifier in a column where the 
// value starts with both alpha and numeric characters, using a
// leading alpha character causes the column and its values to be 
// seen as a strictly a strings/text

$id = "z" . md5(microtime(true));

$row = array
(
    "id" => $id // used for later lookups
    , "name" => "John Doe"
    , "email" => "john@example.com"
    , "comments" => "Hello world"
);

if ($ss->addRow($row)) echo "Form data successfully stored";
else echo "Error, unable to store data";

$row = array
(
    "name" => "John Q Doe"
);

if ($ss->updateRow($row,"id=".$id)) echo "Form data successfully updated";
else echo "Error, unable to update spreadsheet data";

?>

推荐答案

您可以尝试使用下面的代码隐藏 if 以免被窥视.如果您尝试过,它仍然可以被发现,但至少它远离打开的文本视图.它所做的只是在文本中添加字符,然后在使用密码之前减去它们.

You can attempt to hide if from peering eyes using the code below. It would still be discoverable if you tried, but at least it's away from open text view. All it does is add characters to the text and then subtract them before it uses the password.

使用您的原始密码运行此脚本

Run this script using your original password

<?php
$password = "test";

echo "Original Password In Plain Text = $password\n";
$len=strlen($password);

$NewPassword = "";
for( $i = 0; $i <= $len-1; $i++ ) {
$charcode = ord(substr( $password, $i, 1 ));
$NewChar = $charcode+5; $NewLetter = chr($NewChar);
$NewPassword = $NewPassword . $NewLetter;
} echo "Modified Password to Use in Script = $NewPassword\n";

$OrigPassword = "";
for( $i = 0; $i <= $len-1; $i++ ) {
$charcode = ord(substr( $NewPassword, $i, 1 ));
$OrigChar = $charcode-5; $OrigLetter = chr($OrigChar);
$OrigPassword = $OrigPassword . $OrigLetter;
} echo "Convert the Modified back to the Original = $OrigPassword\n";

?>

使用上述脚本中的新密码将此部分添加到您的脚本中

Add this part to your script with the new password from the above script

$password = "yjxy";
$OrigPassword = "";
for( $i = 0; $i <= $len-1; $i++ ) {
$charcode = ord(substr( $password, $i, 1 ));
$OrigChar = $charcode-5; $OrigLetter = chr($OrigChar);
$OrigPassword = $OrigPassword . $OrigLetter;
} $password = $OrigPassword;
echo "Script thinks this is the password = $password\n";

这篇关于如何在 php 中隐藏/保护密码详细信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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