zoukankan      html  css  js  c++  java
  • 把字符串加工成16进制的字节数组并返回

      //把字符串加工成16进制的字节数组并返回(必须要保证数据格式的正确性<字符个数为偶数>)
            public byte[] GetHEXByteArray(string sendvalue)
            {
                
    int sendLength = sendvalue.Length / 2;
                
    byte[] StrBuffer = new byte[sendLength];
                
    string hexstring = "";
                
    int k = 0;
                
    for (int i = 0; i < sendvalue.Length; )
                {
                    hexstring 
    = sendvalue.Substring(i, 2);
                    
    int j;
                    j 
    = int.Parse(hexstring, System.Globalization.NumberStyles.HexNumber);
                    StrBuffer[k] 
    = (byte)j;
                    i 
    += 2;
                    k
    ++;
                }
                
    return StrBuffer;
            }

    ////////////////////////////////
    ////////Sixi. Let it be.../////
    //////////////////////////////

  • 相关阅读:
    爬虫-scrapy初试
    python-爬虫day1
    django 内存地址列表-->转换为-->字典
    django 基于 form 验证 确认密码的注册
    django 请求过程,生命周期
    django7 models 高级应用
    django6-项目练习
    Mysql之起始
    python之IO模型
    python模块之Gevent(协程)
  • 原文地址:https://www.cnblogs.com/sixiweb/p/1430671.html
Copyright © 2011-2022 走看看