return
true ? 'a' :
false ? 'b' :
'c';
这应该返回'a',但它不会.它返回'b'.PHP处理条件运算符的不同部分的顺序是否存在错误?
我从这种情况下的多个条件运算符得到了一个好主意吗?它看起来似乎正常工作.
(当然,真实和假是为了示例的目的.在实际代码中,它们分别是评估为真和假的语句.是的,我知道这肯定)
我正在开发一个项目(基于PHP),我需要在其中计算SHA1,我正在使用这行代码在PHP中生成SHA1.
$da = file_get_contents("payload.txt");
echo sha1($da);
Run Code Online (Sandbox Code Playgroud)
这是.Net的代码
private static string GetSHA1(string text)
{
UnicodeEncoding UE = new UnicodeEncoding();
byte[] hashValue;
byte[] message = UE.GetBytes(text);
SHA1Managed hashString = new SHA1Managed();
string hex = "";
hashValue = hashString.ComputeHash(message);
foreach (byte x in hashValue)
{
hex += String.Format("{0:x2}", x);
}
return hex;
}
Run Code Online (Sandbox Code Playgroud)
但我很困惑,因为两种语言都会产生不同的结果,我不会在它们两者中提供任何盐(因为我不知道在盐b/c中使用什么,api没有定义它)
我之后还需要处理RSA(我有一个加密密钥)也可以有人说,这些算法是否因语言或我遗漏的任何东西而有所不同?
需要一些专家对此的意见
这是生成SHA1和RSA加密的整个算法
<?php
class MyEncryption
{
public $pubkey = '...public key here...';
public $privkey = '...private key here...';
public function encrypt($data)
{
if (openssl_private_encrypt($data, $encrypted, $this->pubkey))
$data = …Run Code Online (Sandbox Code Playgroud)