15-08-13, 03:39 PM
اولا في C#
اولا نقوم بادراج المكتبات
وهذه الدالة تعود با هاش كود
ثانيا في VB.NET
المكتبات
والان لنشاهد لمسة PHP السحرية فقط
ستعود الدالة md5 بالهاش كود تبع النص فرق شاسع انهوا سحر php
اولا نقوم بادراج المكتبات
كود :
using System.Security;
using System.Security.Cryptography;كود :
public static string CalculateMD5Hash(string input)
{
// step 1, calculate MD5 hash from input
MD5 md5 = System.Security.Cryptography.MD5.Create();
byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input);
byte[] hash = md5.ComputeHash(inputBytes);
// step 2, convert byte array to hex string
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hash.Length; i++)
{
sb.Append(hash[i].ToString("X2"));
}
return sb.ToString();
}ثانيا في VB.NET
المكتبات
كود :
Imports System.Security
Imports System.Security.Cryptographyكود :
Public Shared Function CalculateMD5Hash(input As String) As String
' step 1, calculate MD5 hash from input
Dim md5 As MD5 = System.Security.Cryptography.MD5.Create()
Dim inputBytes As Byte() = System.Text.Encoding.ASCII.GetBytes(input)
Dim hash As Byte() = md5.ComputeHash(inputBytes)
' step 2, convert byte array to hex string
Dim sb As New StringBuilder()
For i As Integer = 0 To hash.Length - 1
sb.Append(hash(i).ToString("X2"))
Next
Return sb.ToString()
End Functionوالان لنشاهد لمسة PHP السحرية فقط
كود :
[md5($string)ستعود الدالة md5 بالهاش كود تبع النص فرق شاسع انهوا سحر php
