Exemplo n.º 1
0
        //***********************************************************************************************************************

        //***********************************************************************************************************************
        /// <summary>
        ///
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        //-----------------------------------------------------------------------------------------------------------------------
        static public string GetString(String source)
        {
            //-------------------------------------------------------------------------------------------------------------------
            Md5Encryptor md = Md5Encryptor.Create();

            byte[] hash;

            UTF8Encoding enc = new UTF8Encoding();

            //-------------------------------------------------------------------------------------------------------------------

            //-------------------------------------------------------------------------------------------------------------------
            byte[] buffer = enc.GetBytes(source);

            hash = md.ComputeHash(buffer);

            StringBuilder sb = new StringBuilder();

            //-------------------------------------------------------------------------------------------------------------------

            //-------------------------------------------------------------------------------------------------------------------
            foreach (byte b in hash)
            {
                sb.Append(b.ToString("x2"));
            }

            return(sb.ToString());
            //-------------------------------------------------------------------------------------------------------------------
        }
Exemplo n.º 2
0
        //***********************************************************************************************************************

        //***********************************************************************************************************************
        /// <summary>
        ///
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        //-----------------------------------------------------------------------------------------------------------------------
        static public byte[] GetBytes(byte[] source)
        {
            //-------------------------------------------------------------------------------------------------------------------
            return(Md5Encryptor.Create().ComputeHash(source));
            //-------------------------------------------------------------------------------------------------------------------
        }