当前位置: 首页>>代码示例>>C#>>正文


C# Byte.Concat方法代码示例

本文整理汇总了C#中System.Byte.Concat方法的典型用法代码示例。如果您正苦于以下问题:C# Byte.Concat方法的具体用法?C# Byte.Concat怎么用?C# Byte.Concat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Byte的用法示例。


在下文中一共展示了Byte.Concat方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FromByteArray

 public static String FromByteArray(Byte[] b, Byte version)
 {
     SHA256 sha256 = new SHA256Managed();
     b = (new Byte[] { version }).Concat(b).ToArray();
     Byte[] hash = sha256.ComputeHash(sha256.ComputeHash(b)).Take(4).ToArray();
     return Base58String.FromByteArray(b.Concat(hash).ToArray());
 }
开发者ID:LawrenceBotley,项目名称:LBitcoin,代码行数:7,代码来源:Base58CheckString.cs

示例2: DeleteFile

        public void DeleteFile(List<string> names)
        {
            TcpClient tcpClient = null;
            NetworkStream stream = null;
            try
            {
                tcpClient = new TcpClient(ip, port);

                stream = tcpClient.GetStream();

                Byte[] dataToSend = new Byte[1];
                dataToSend[0] = (byte)TcpPacketType.Delete;
                
                StringBuilder sb = new StringBuilder();
                if (names.Count > 0)
                {
                    for (int i = 0; i < names.Count - 1; i++)
                    {
                        sb.Append(names[i] + "#");
                    }
                    sb.Append(names[names.Count - 1]);
                }
                dataToSend = dataToSend.Concat(System.Text.Encoding.UTF8.GetBytes(sb.ToString())).ToArray();
                stream.Write(dataToSend, 0, dataToSend.Length);
                stream.Flush();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            finally
            {
                stream.Close();
                tcpClient.Close();
            }
        }
开发者ID:wangws556,项目名称:duoduo-chat,代码行数:36,代码来源:TcpAsynchronousClient.cs

示例3: UploadFile

        public bool UploadFile()
        {
            TcpClient tcpClient = null;
            NetworkStream stream = null;
            try
            {
                tcpClient = new TcpClient(ip,port);

                stream = tcpClient.GetStream();
                Byte[] name = System.Text.Encoding.UTF8.GetBytes(System.IO.Path.GetFileName(file));
                Byte[] dataToSend = new Byte[name.Length + 5];
                dataToSend[0] = (byte)TcpPacketType.Upload;
                Buffer.BlockCopy(BitConverter.GetBytes(name.Length), 0, dataToSend, 1, 4);
                Buffer.BlockCopy(name, 0, dataToSend, 5, name.Length);


                using (System.IO.FileStream fs = System.IO.File.Open(file, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite))
                {
                    int numBytesToRead = Convert.ToInt32(fs.Length);
                    byte[] oFileBytes = new byte[(numBytesToRead)];
                    fs.Read(oFileBytes, 0, numBytesToRead);
                    dataToSend = dataToSend.Concat(oFileBytes).ToArray();
                    stream.Write(dataToSend, 0, dataToSend.Length);
                    stream.Flush();
                }

                //byte[] backData = new byte[4];
                //stream.Read(backData, 0, 4);
                //int length = BitConverter.ToInt32(backData, 0);
                //if (length == dataToSend.Length)
                //{
                    return true;
                //}
                //else
                //{
                //    return false;
                //}

            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return false;
            }

            finally
            {
                stream.Close();
                tcpClient.Close();
            }
           
        }
开发者ID:wangws556,项目名称:duoduo-chat,代码行数:52,代码来源:TcpAsynchronousClient.cs

示例4: GenerateMessageId

        private MessageId GenerateMessageId(EMail Mail, String DomainPart = null)
        {
            if (DomainPart.IsNullOrEmpty())
                DomainPart = base.RemoteHost;

            var RandomBytes  = new Byte[16];
            _Random.NextBytes(RandomBytes);

            var HashedBytes = _SHAHasher.ComputeHash(RandomBytes.
                                                     Concat(Mail.From.   ToString().ToUTF8Bytes()).
                                                     Concat(Mail.Subject.           ToUTF8Bytes()).
                                                     Concat(Mail.Date.   ToString().ToUTF8Bytes()).
                                                     ToArray());

            return MessageId.Parse(HashedBytes.ToHexString().Substring(0, 24) + "@" + DomainPart);
        }
开发者ID:Vanaheimr,项目名称:Hermod,代码行数:16,代码来源:SMTPClient.cs

示例5: Prepare

        public Byte[] Prepare(Byte[] m)
        {
            Byte[] endByteArray = new Byte[c];

            //Füllt EndArray
            for (int i = 0; i < c; i++)
            {
                endByteArray[i] = 255;
            }

            while (m.Length % c != 0)
            {
                m = m.Concat(new Byte[] { 255 }).ToArray();
            }

            return m.Concat(endByteArray).ToArray();
        }
开发者ID:titoo123,项目名称:SPS_Connection_Test,代码行数:17,代码来源:Paket.cs

示例6: Encrypt

 /// <summary>
 ///     DES加密
 /// </summary>
 /// <param name="plain">字符串表示的16进制明文</param>
 /// <param name="key"></param>
 /// <returns></returns>
 public static string Encrypt(string plain, Byte[] key)
 {
     //密钥不足8byte,补足
     if (key.Length < 8)
     {
         key = key.Concat(new Byte[8 - key.Length]).ToArray();
     }
     List<Byte> pBytes = new List<byte>(plain.HexStringToBytes());
     //明文的长度不是8的倍数,补足
     while (pBytes.Count%8 != 0)
     {
         pBytes.Add(new byte());
     }
     var bytes = pBytes.ToArray();
     byte[] p = new byte[8];
     StringBuilder sb = new StringBuilder();
     //每8Byte进行一次DES加密,结果拼接
     for (int i = 0; i < bytes.Length; i += 8)
     {
         Array.ConstrainedCopy(bytes, i, p, 0, 8);
         sb.Append(DES.Encrypt(p, key).PrintInHex());
     }
     return sb.ToString();
 }
开发者ID:UlyssesWu,项目名称:Encryption,代码行数:30,代码来源:DES.cs

示例7: Decrypt

 /// <summary>
 ///     DES解密
 /// </summary>
 /// <param name="input"></param>
 /// <param name="key"></param>
 /// <returns></returns>
 public static string Decrypt(string input, Byte[] key)
 {
     if (key.Length < 8)
     {
         key = key.Concat(new Byte[8 - key.Length]).ToArray();
     }
     List<Byte> pBytes = new List<byte>(input.HexStringToBytes());
     while (pBytes.Count%8 != 0)
     {
         pBytes.Add(new byte());
     }
     var bytes = pBytes.ToArray();
     byte[] p = new byte[8];
     StringBuilder sb = new StringBuilder();
     for (int i = 0; i < bytes.Length; i += 8)
     {
         Array.ConstrainedCopy(bytes, i, p, 0, 8);
         sb.Append(DES.Decrypt(p, key).PrintInHex());
     }
     return sb.ToString();
 }
开发者ID:UlyssesWu,项目名称:Encryption,代码行数:27,代码来源:DES.cs


注:本文中的System.Byte.Concat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。