Merhaba,
Seneler önce asp2php gibi bir yazılım ile asp kodlarını php'ye convert
edebiliyorduk. Şimdi ufak bir kod parçasını php'ye çevirmem gerekiyor.
bunu online yapan bir servis ya da bana yardımcı olabilecek bir
arkadaş mevcut mu? ben bir şeyler yaptım ama maalesef başarılı
olamadım.
çevirmeye çalıştığım kod aşağıdaki şekilde :
using System.Text;
using System.Security.Cryptography;
private string CreateHashHex(string pH)
{
return ByteToHex(CreateSHA1(pH));
}
private string CreateHashBase64(string pH)
{
return Convert.ToBase64String(CreateSHA1(pH));
}
private byte[] CreateSHA1(string pH)
{
SHA1 sha = new SHA1CryptoServiceProvider();
byte[] byt = Encoding.GetEncoding(0).GetBytes(pH);
byte[] hash = sha.ComputeHash(byt);
return hash;
}
private string ByteToHex(byte[] byteText)
{
StringBuilder strB = new StringBuilder();
foreach (byte b in byteText)
{
strB.Append(b.ToString("X").PadLeft(2, '0'));
}
return strB.ToString();
}
php olarak (anladığım kadarıyla) çevirdiğim hali bu şekilde:
function string_to_hex($string)
{
$hex='';
$string = sha1($string);
for ($i=0; $i < strlen($string); $i++)
{
$hex .= dechex(ord($string[$i]));
}
return $hex;
}
Saygılarımla...
_______________________________________________
Linux-programlama mailing list
[email protected]
https://liste.linux.org.tr/mailman/listinfo/linux-programlama
Liste kurallari: http://liste.linux.org.tr/kurallar.php