Encodes bytes to a base16 string. - CSharp System

CSharp examples for System:String Base

Description

Encodes bytes to a base16 string.

Demo Code


using System.Security.Cryptography;
using System;/*from  w w  w.j  a  v a2s.  co m*/

public class Main{
        /// <summary>
        /// Encodes bytes to a base16 string.
        /// </summary>
        public static String Encode(Byte[] bytes)
        {
            String hex = "";
            for (Int32 i = 0; i < bytes.Length; i++)
            {
                hex += bytes[i].ToString("x2");
            }
            return hex;
        }
}

Related Tutorials