Ejemplo n.º 1
0
                /// <summary>
                /// 异或解密
                /// </summary>
                /// <param name="content"></param>
                /// <param name="password"></param>
                /// <returns></returns>
                public static byte[] XORDecrypt(byte[] encryptedBytes, string password)
                {
                    var sourceContent = string.Empty;

                    if (string.IsNullOrEmpty(password))
                    {
                        FrameworkLog.Error("传入密码为空,无法解密");
                        return(encryptedBytes);
                    }
                    var passwordArray  = Encoding.Default.GetBytes(password);
                    var passwordLength = passwordArray.Length;

                    for (var i = 0; i < encryptedBytes.Length; i++)
                    {
                        var p = passwordArray[i % passwordLength];
                        encryptedBytes[i] = (byte)(encryptedBytes[i] ^ p);
                    }
                    return(encryptedBytes);
                }
Ejemplo n.º 2
0
                /// <summary>
                /// 错误处理
                /// </summary>
                /// <param name="pUWR"></param>
                /// <returns></returns>
                private static FrameworkStateCode ErrorHandle(UnityWebRequest pUWR)
                {
                    var code = FrameworkStateCode.Succeed;

                    if (pUWR.isNetworkError || pUWR.isHttpError)
                    {
                        FrameworkLog.Error(
                            $"HttpGet网络错误\nErrorMsg:{pUWR.error} Type:{pUWR} isNetworkError:{pUWR.isNetworkError} isHttpError:{pUWR.isHttpError}\nurl:{pUWR}");
                        code = FrameworkStateCode.Error;
                        return(code);
                    }
                    if (!pUWR.isDone)
                    {
                        FrameworkLog.Error($"HttpGet访问超时\nErrorMsg:{pUWR.error} Type:{pUWR} isDone:{pUWR.isDone} \nurl:{pUWR.url}");
                        code = FrameworkStateCode.TimeOut;
                        return(code);
                    }
                    return(code);
                }
Ejemplo n.º 3
0
                /// <summary>
                /// 异或加密
                /// </summary>
                /// <param name="content"></param>
                /// <param name="password"></param>
                /// <returns></returns>
                public static byte[] XOREncrypt(byte[] sourceByte, string password)
                {
                    var encryptedContent = string.Empty;

                    if (string.IsNullOrEmpty(password))
                    {
                        FrameworkLog.Error("传入密码为空,无法加密");
                        return(sourceByte);
                    }
                    var sourceContentArray = sourceByte;
                    var passwordArray      = Encoding.Default.GetBytes(password);
                    var passwordLength     = passwordArray.Length;

                    for (var i = 0; i < sourceContentArray.Length; i++)
                    {
                        var p = passwordArray[i % passwordLength];
                        sourceContentArray[i] = (byte)(sourceContentArray[i] ^ p);
                    }
                    return(sourceContentArray);
                }