简体   繁体   English

根据发布变量编码SHA-1字符串

[英]Encoding an SHA-1 string based on post variables

I'm trying to find a service that will allow me to POST to that will return an SHA-1 encoded string based off of the variables that I pass to it. 我试图找到一种服务,该服务将允许我发布到该服务,该服务将基于传递给我的变量返回一个SHA-1编码的字符串。

I haven't been able to find one so I've thought about writing my own PHP solution. 我找不到一个,所以我考虑过编写自己的PHP解决方案。

If I end up going this route, is there a specific best practice in PHP for creating SHA-1 stings? 如果我最终走这条路,那么在PHP中是否有创建SHA-1 st的特定最佳实践?

Here is an example from the php manual 这是php手册中的示例

$str = 'apple';

if (sha1($str) === 'd0be2dc421be4fcd0172e5afceea3970e2f3d940') {
    echo "Would you like a green or red apple?";
}

Use sha1() : 使用sha1()

sha1 — Calculate the sha1 hash of a string sha1 —计算字符串的sha1哈希

An example: 一个例子:

<?php
$str = 'apple';

if (sha1($str) === 'd0be2dc421be4fcd0172e5afceea3970e2f3d940') {
    echo "Would you like a green or red apple?";
}
?>

(source: sha1() documentation ) (来源: sha1()文档

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM