Hello i want this code in php, can you help me.
byte[] test1 = new byte[j];
UnicodeEncoding unicodeEncoding = new UnicodeEncoding();
test1 = unicodeEncoding.GetBytes(data1);
byte[] test2 = new SHA1Managed().ComputeHash(test1);
Have try this
$test1 = mb_convert_encoding($data1, "UTF-16LE");
$test2 = sha1($test1);
Thanks all
I run this code and the output are SHA1:D7672B17EE7830F77526DB72540C468E8865CB91
string str1;
string input = "@ztzeré$!]=°°452345é";
byte[] bs3 = Encoding.ASCII.GetBytes(input);
Encoding encoding = Encoding.UTF8;
str1 = encoding.GetString(bs3);
UnicodeEncoding unicodeEncoding = new UnicodeEncoding();
bs3 = unicodeEncoding.GetBytes(str1);
byte[] bs2 = new SHA1Managed().ComputeHash(bs3);
string str5 = BitConverter.ToString(bs2);
string str7 = str5.Replace("-", "");
Console.WriteLine("SHA1:" + str7);
Now i run on php this code and the output are SHA1:94D034942FE42A3AD2978F6196223BCBFE87F1F1
$input1 = utf8_encode('@ztzeré$!]=°°452345é');
$input2 = mb_convert_encoding($input1, "UTF-16");
$input3 = strtoupper(sha1($input2));
echo "SHA1:$input3
";
C#
Encoding.ASCII.GetBytes(input);
PHP
function EncodingASCII($input) {
if($input) {
$output = ''; $b = 0;
for($i = 0; $i < strlen($input); $i++) {
if($input[$i] > chr(127)) {
$output[$b] = "?";
$i++;
} else {
$output[$b] = $input[$i];
}
$b++;
}
return implode($output);
} else {
return false;
}
}
C#
UnicodeEncoding unicodeEncoding = new UnicodeEncoding();
bs3 = unicodeEncoding.GetBytes(str1);
PHP
mb_convert_encoding($test, "UCS-2LE", "JIS, eucjp-win, sjis-win");