C# 实现异或校验(BCC)


public static String ToBCC(this String Str)
{
    try
    {
        Int32 code = 0;
        Char[] chars = Str.ToCharArray();
        for (Int32 i = 0; i < chars.Length; i++) { code ^= Convert.ToInt32(chars[i]); }
        return code.ToString("X");
    }
    catch { return null; }
}
public static String ToBCC(this Byte[] bytes)
{
    try
    {
        Int32 code = 0;
        for (Int32 i = 0; i < bytes.Length; i++) { code ^= bytes[i]; }
        return code.ToString("X");
    }
    catch { return null; }
}

(152)
打赏 支付红包 支付红包 微信打赏 微信打赏
上一篇 2023-04-03 13:07:31
下一篇 2023-05-02 20:32:08

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信