php - PHP加密,加密时考虑空行
问题描述
我正在使用一些 c# 代码访问的 PHP 中的一些加密,
当我对以下内容进行 sha1 加密时test1:test1:apple
,每个在线生成器都会返回:8ee27a0e9368d2835b3fdeb4b50caf1d8f790314
但是,当我运行我的 PHP 脚本时,它会返回296b39344a6eb9d88c3bb1122f5941f0bcf3b0c2
。test1:test1:apple
因为本质上它是在我正在加密的字符串 ( ) 中添加一个空行。
有谁知道如何解决这个问题?这不一定是世界上最糟糕的事情,它只是非常烦人。
我使用的代码非常简单:
function GetRandomWord()
{
$file = "../Core/nouns0.txt";
$file_arr = file($file);
$num_lines = count($file_arr);
$last_index = $num_lines -1;
$rand_index = rand(0, $last_index);
$rand_text = $file_arr[$rand_index];
return $rand_text;
}
$enc = GetRandomWord();
$encrypted = sha1("$username:$password:$enc");
echo $encrypted;
它被脚本捕获在 c# 中。
提前致谢!
解决方案
@IłyaBursov 他们的回答有帮助!我将 GetRandomWord() 函数的 return 语句更改为
return trim($rand_text);
谢谢!
推荐阅读
- javascript - Thymeleaf - 如何交互和重新加载 Javascript?
- python - 使用 Python 请求模块下载的文件引发无效文件错误
- java - 如果 pg_restore 正在进行,我们会在应用程序中遇到任何运行时问题吗?
- javascript - 如何找到 React 函数的作用域?
- javascript - 为什么我的代码在文本字段中给出的时间没有重新加载
- mysql - 如何让关注用户发布具有可见性条件的提要?
- python - 基于 GPIO 输入和时间的 Python rpi GPIO 输出控制
- openoffice-calc - OpenOffice Calc 使用许多 cels 将二进制代码转换为十进制
- android - 单元测试 ViewModel 类
- mongodb - Create array if not exists or append item to existing