zoukankan      html  css  js  c++  java
  • C#与c之间通信之一校验字

     c# 获取校验字 :

         private static string GetCheckSum(string Message)
          {
              byte initCheck = 0;
              byte[] bs = Encoding.GetEncoding("GB2312").GetBytes(Message);


           

              foreach (byte c in bs)
              {
                  initCheck ^= c;
                
              }
              string a = Convert.ToString(initCheck, 16);

              return a;
          }

    c++ 则是:

    int CProc::GetChksum(const char *strMsg)
    {
     int nCk ;
     int nLen = strlen(strMsg);
     nCk = 0;
     for(int i = 0; i < nLen; i++ )
     {
      nCk = nCk ^ strMsg[i];
     }

     return nCk;
    }

  • 相关阅读:
    HUD--2553 N皇后问题
    poj--2139
    poj--2236
    poj--2229
    poj--2376 Cleaning Shifts
    poj--3669
    poj--1979 Red and Black
    poj--1258
    经典DP问题--poj1088滑雪
    Poj 1041--欧拉回路
  • 原文地址:https://www.cnblogs.com/glf123/p/2230429.html
Copyright © 2011-2022 走看看