Home > Net >  A c # code for the great god turn to Python, thank you
A c # code for the great god turn to Python, thank you

Time:09-24

Public static string CreateToken (string message, string secret)
{
Secret=secret?? "";
Var encoding=new System. Text. UTF8Encoding (); and
Byte [] keyByte=encoding. GetBytes (secret);
Byte [] messageBytes=encoding. GetBytes (message);
Using (var hmacsha256=new hmacsha256 (keyByte))
{
Byte [] hashmessage=hmacsha256.Com puteHash (messageBytes);
Return BitConverter. ToString (hashmessage). Replace (" - ", ""). ToLower ();
}
}

CodePudding user response:

This wouldn't have turned, you understand it directly find

This code is "HMACSHA256 encryption algorithm
"Baidu directly into "https://www.baidu.com/s? Wd=python % 20 hmacsha256 & amp; Rsv_spt=1 & amp; Rsv_iqid=0 x9322cdd0000b3bdb & amp; Issp=1 & amp; F=8 & amp; Rsv_bp=1 & amp; Rsv_idx=2 & amp; Ie=utf-8 & amp; Tn=baiduhome_pg & amp; Rsv_enter=1 & amp; Rsv_dl=tb& Rsv_n=2 & amp; Rsv_sug3=8 & amp; Rsv_sug1=2 & amp; Rsv_sug7=100 & amp; Rsv_sug2=0 & amp; InputT=5588 & amp; Rsv_sug4=5589"

CodePudding user response:

reference 1st floor wanghui0380 response:
this wouldn't have turned, you understand it directly find

This code is "HMACSHA256 encryption algorithm
"Baidu directly into "https://www.baidu.com/s? Wd=python % 20 hmacsha256 & amp; Rsv_spt=1 & amp; Rsv_iqid=0 x9322cdd0000b3bdb & amp; Issp=1 & amp; F=8 & amp; Rsv_bp=1 & amp; Rsv_idx=2 & amp; Ie=utf-8 & amp; Tn=baiduhome_pg & amp; Rsv_enter=1 & amp; Rsv_dl=tb& Rsv_n=2 & amp; Rsv_sug3=8 & amp; Rsv_sug1=2 & amp; Rsv_sug7=100 & amp; Rsv_sug2=0 & amp; InputT=5588 & amp; Rsv_sug4=5589 "

I tried both the length of the encryption algorithm encryption comes out is not the same

CodePudding user response:

Hey, turn a corner.

UTF8
  •  Tags:  
  • C#
  • Related