天天看點

将經過Base64編碼的byte[]解碼

經過編碼的:string stt="7E 12 13 72 41 22 51 41 41 42 30 41 21 42 41 41 42 41 41 41 48 51 41 41 67 37 68 43 51 4F 68 75 78 5A 45 32 77 30 44 4A 50 48 35 50 6C 45 75 65 46 77 63 7A 39 58 64 33 50 77 53 55 68 78 4B 69 30 35 4C 76 31 49 41 3D 3D 7F"

        /// <summary>

        /// 字元串轉十六進制

        /// </summary>

        /// <param name="str"></param>

        /// <returns></returns>

        private byte[] StringToHex(string str)

        {

            string[] strs = str.Split(' ');

            byte[] bytes = new byte[strs.Length];

            int index = 0;

            foreach (string s in strs)

            {

                int hex = Convert.ToInt32(s, 16);

                bytes[index++] = (byte)hex;

            }

            return bytes;

        }

byte[] conding=StringToHex(str);

 //解碼

            byte[] decondeByte = Convert.FromBase64CharArray(new ASCIIEncoding().GetChars(conding,0,conding.Length),0,conding.Length);

decondeByte就是經過Base64解碼之後的Byte[]