الوسوم:
  1. Fox

    Fox Developer

    الأنتساب:
    ‏27 ديسمبر 2011
    المشاركات:
    81
    الإعجابات المتلقاة:
    3
    نقاط الجائزة:
    8
    الإقامة:
    ŖĬỹДďҢ
    [​IMG]


    In this post I will be demonstrating a simple C# method that can be utilized to encrypt a string (password) to MD5 hash

    The MD5 message-digest algorithm is a widely used cryptographic hash function producing a 128-bit (16-byte) hash value, typically expressed in text format as a 32 digit hexadecimal number. MD5 has been utilized in a wide variety of cryptographic applications, and is also commonly used to verify data integrity. (From Wikipedia)

    [YOUTUBE]NiW5RiPkQdI[/YOUTUBE]

    To use the MD5 encryption in your application you should include the <System.Security.Cryptography> Namespace using the code above

    [C#]using System.Security.Cryptography;[/C#]

    The Bloc code below carries a method (GetMD5) that convert a chain to an MD5 hash, returning a 32 characters, white one string parameter
    GetMD5 function

    [C#] public string GetMD5(string text)
    {
    MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
    md5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(text));
    byte[] result = md5.Hash;
    StringBuilder str = new StringBuilder();
    for (int i = 0; i < result.Length; i++)
    {
    str.Append(result.ToString("x2"));
    }
    return str.ToString();
    } [/C#]

    To use the GetMD5 method

    [C#]string result = GetMD5("iq-team"); [/C#]

    MD5 hash for iq-team is : 8cbadb17d3aeefcf8b7e786894488a62
     
  2. Ameer Eagle

    Ameer Eagle V • I • P

    الأنتساب:
    ‏7 يونيو 2014
    المشاركات:
    3,233
    الإعجابات المتلقاة:
    2,779
    نقاط الجائزة:
    113
    الجنس:
    ذكر
    الوظيفة:
    Student
    الإقامة:
    IraQ
    رد: Encrypt your passwords with MD5 hashing in C#

    Hello thank you for adding the topic is very beautiful
    Very, very useful and God bless oh-Ghali champion New Nntdhar
     

مشاركة هذه الصفحة