예제 #1
0
        void ManualAuthCallBack(mm.command.NewAuthResponse message)
        {
            if (message.Base.Ret == -301)
            {
                var dns = message.Server.NewHostList;
                if (dns.ListList.Count > 0)
                {
                    string ip = dns.ListList[0].Substitute;

                    mMClient.shortLink = "http://" + dns.ListList[1].Substitute;
                    Console.WriteLine("shortLink:" + mMClient.shortLink + "\n");
                    mMClient.ReConnect(ip);
                    mMClient.CheckLoginQRCode(uuid, CheckLoginQRCodeCallBack);
                }
            }
            else if (message.Base.Ret == 0)
            {
                byte[] strECServrPubKey = message.Auth.SvrPubECDHKey.Key.Buffer.ToByteArray();
                var    aesKey           = MyFuckSSL.SharkEcdhKey(strECServrPubKey, mMClient.pri_key_buf);
                mMClient.CheckEcdh = aesKey.ToString(16, 2);
                mMClient.AESKey    = AES.AESDecrypt(message.Auth.SessionKey.Buffer.ToByteArray(), aesKey).ToString(16, 2);
                mMClient.wxid      = message.User.UserName;
                Console.WriteLine("当前微信号:" + mMClient.wxid + "\n");
                mMClient.uin = message.Auth.Uin;
                Console.WriteLine("uin:" + mMClient.uin + "\n");
                mMClient.cookie = mMClient.getcookie();

                mMClient.deviceID = "49aa7db2f4a3ffe0e96218f6b92cde32".ToByteArray(16, 2);
                Console.WriteLine(ChangeType.ToHexString(mMClient.deviceID));
                mMClient.devicetype = "iPad iPhone OS8.4";
                ShortChanle.NewInit(mMClient);
            }
        }
예제 #2
0
    public static MsgBase Decode(ProtocolEnum protocol, byte[] bytes, int offset, int count)
    {
        if (count <= 0)
        {
            Debug.LogError("协议解密出错,数据长度为0");
            return(null);
        }

        try
        {
            byte[] newBytes = new byte[count];
            Array.Copy(bytes, offset, newBytes, 0, count);
            string secret = ServerSocket.Secretkey;
            if (protocol == ProtocolEnum.MsgSecret)
            {
                secret = ServerSocket.PublicKey;
            }
            newBytes = AES.AESDecrypt(newBytes, secret);

            using (var memory = new MemoryStream(newBytes, 0, newBytes.Length))
            {
                Type t = System.Type.GetType(protocol.ToString());
                return((MsgBase)Serializer.NonGeneric.Deserialize(t, memory));
            }
        }
        catch (Exception ex)
        {
            Debug.LogError("协议解密出错:" + ex);
            return(null);
        }
    }
예제 #3
0
        public HttpResponseMessage CreatePayOrder()
        {
            HttpResponseMessage response = null;
            PayOrder            payOrder = new PayOrder();

            try
            {
                List <Order> orders = null;
                using (var ms = new MemoryStream())
                {
                    HttpContext.Current.Request.GetBufferlessInputStream().CopyTo(ms);
                    if (ms.Length != 0)
                    {
                        var cText = WebCommom.HttpRequestBodyConvertToStr(ms);//密文
                        var pText = AES.AESDecrypt(cText, AESKey);
                        orders = JsonConvert.DeserializeObject <List <Order> >(pText);
                    }
                }
                if (orders != null)
                {
                    payOrder.Orders = orders;
                    payOrder.ID     = payOrderBll.Value.CreatePayOrder(payOrder);
                }
            }
            catch (Exception ex)
            {
            }
            var responseCText = AES.AESEncrypt(JsonConvert.SerializeObject(payOrder), AESKey);//返回密文

            response = WebCommom.GetResponse(responseCText);
            return(response);
        }
예제 #4
0
        /// <summary>
        /// 协议解密,以及反序列化
        /// </summary>
        /// <param name="protocol"></param>
        /// <param name="bytes"></param>
        /// <param name="offset"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public static MessageBase Decode(ProtocolEnum protocol, byte[] bytes, int offset, int count)
        {
            if (count <= 0)
            {
                Debug.LogError("协议解密出错,数据长度为0");
                return(null);
            }
            try
            {
                byte[] newBytes = new byte[count];
                Array.Copy(bytes, offset, newBytes, 0, count);
                string secret = ServerSocket.SecretKey;
                // 请求加密使用的是公钥加密
                if (protocol == ProtocolEnum.MessageSecret)
                {
                    secret = ServerSocket.PublicKey;
                }

                // 解密
                newBytes = AES.AESDecrypt(newBytes, secret);

                using (var memory = new MemoryStream(newBytes, 0, newBytes.Length))
                {
                    // 这里要求对应的协议类型类,要与协议枚举的名字一一对应(这里的类最好不要有命名空间包裹,若有,可能识别不到)
                    Type t = System.Type.GetType(protocol.ToString());
                    return((MessageBase)Serializer.NonGeneric.Deserialize(t, memory));
                }
            }
            catch (Exception ex)
            {
                Debug.LogError("协议解密出错 :" + ex);
                return(null);
            }
        }
예제 #5
0
    /// <summary>
    /// 协议解密,以及反序列化
    /// </summary>
    /// <param name="protocol"></param>
    /// <param name="bytes"></param>
    /// <param name="offset"></param>
    /// <param name="count"></param>
    /// <returns></returns>
    public static MessageBase Decode(ProtocolEnum protocol, byte[] bytes, int offset, int count)
    {
        if (count <= 0)
        {
            Debug.LogError("协议解密出错,数据长度为0");
            return(null);
        }
        string secret = string.IsNullOrEmpty(NetManager.Instance.Secretkey) ? NetManager.Instance.PublicKey :
                        NetManager.Instance.Secretkey;

        try
        {
            byte[] newBytes = new byte[count];
            Array.Copy(bytes, offset, newBytes, 0, count);


            //// 解密
            newBytes = AES.AESDecrypt(newBytes, secret);

            using (var memory = new MemoryStream(newBytes, 0, newBytes.Length))
            {
                // 这里要求对应的协议类型类,要与协议枚举的名字一一对应
                Type t = System.Type.GetType(protocol.ToString());
                return((MessageBase)Serializer.NonGeneric.Deserialize(t, memory));
            }
        }
        catch (Exception ex)
        {
            Debug.LogError("协议解密出错 :" + ex);
            return(null);
        }
    }
예제 #6
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.A))
        {
            string text    = "test";
            byte[] aesByte = Encoding.UTF8.GetBytes(text);
            print("加密前:" + text);
            aesByte = AES.AESEncrypt(aesByte);
            print("加密后:" + Encoding.UTF8.GetString(aesByte));
            aesByte = AES.AESDecrypt(aesByte);
            print("解密后:" + Encoding.UTF8.GetString(aesByte));
        }


        if (Input.GetKeyDown(KeyCode.B))
        {
            print(Application.dataPath);

            if (assetBundel != null)
            {
                print(assetBundel.Load("Cube").name);
            }
            else
            {
                StartCoroutine(LoadRes());
            }
        }
    }
예제 #7
0
        static void Main(string[] args)
        {
            RSA    rsa = new RSA();
            string key = "12345678";
            string content = "123456";
            string str1 = DES.Encrypt(content, key);
            string arr1 = DES.Decrypt(str1, key);
            string str2 = AES.AESEncrypt(content, key);
            string arr2 = AES.AESDecrypt(str2, key);
            string privatekey, publickey;

            rsa.RSAKey(out privatekey, out publickey);
            string str3 = rsa.RSAEncrypt(publickey, content);
            string arr3 = rsa.RSADecrypt(privatekey, str3);
            string str4 = MD5Crypto.MD5Encrypt(content);
            string str5 = Base64code.Base64.ToBase64String(content);
            string arr5 = Base64code.Base64.UnBase64String(str5);

            Console.WriteLine(str1);
            Console.WriteLine(arr1);
            Console.WriteLine(str2);
            Console.WriteLine(arr2);
            Console.WriteLine(str3);
            Console.WriteLine(arr3);
            Console.WriteLine(publickey);
            Console.WriteLine(privatekey);
            Console.WriteLine(str4);
            Console.WriteLine(str5);
            Console.WriteLine(arr5);
            Console.Read();
        }
예제 #8
0
파일: Form1.cs 프로젝트: zhangjanp/WeChatXY
        private void checkManualAuth(string wxnewpass, string wxid)
        {
            var ManualAuth = wechat.ManualAuth(wxnewpass, wxid);

            //-301重定向
            Console.WriteLine(ManualAuth.baseResponse.ret);
            if (ManualAuth.baseResponse.ret == MMPro.MM.RetConst.MM_ERR_IDC_REDIRECT)
            {
                //Console.WriteLine(ManualAuth.dnsInfo.builtinIplist.shortConnectIplist[0].ip);
                //byte[] s = Util.Serialize<MM.BuiltinIP>(ManualAuth.dnsInfo.builtinIplist.shortConnectIplist.shortConnectIplist[1]);
                int len = (int)ManualAuth.dnsInfo.builtinIplist.shortconnectIpcount;
                Util.shortUrl = "http://" + ManualAuth.dnsInfo.newHostList.list[1].substitute;
                put(Util.shortUrl);

                //继续检查状态
                //chek.Start();
                checkLogin(uuid);
            }
            else if (ManualAuth.baseResponse.ret == MMPro.MM.RetConst.MM_OK)
            {
                MyWxid = ManualAuth.accountInfo.wxid;

                put(ManualAuth.accountInfo.wxid);
                put(ObjToJson2 <MM.AccountInfo>(ManualAuth.accountInfo));
                put(ObjToJson2 <MM.BaseResponse>(ManualAuth.baseResponse));
                put(JsonConvert.SerializeObject(ManualAuth.authParam));

                byte[] strECServrPubKey = ManualAuth.authParam.ecdh.ecdhkey.key;
                byte[] aesKey           = new byte[16];
                Xcode.ComputerECCKeyMD5(strECServrPubKey, 57, wechat.pri_key_buf, 328, aesKey);
                //var aesKey = OpenSSLNativeClass.ECDH.DoEcdh(ManualAuth.authParam.ecdh.nid, strECServrPubKey, wechat.pri_key_buf);
                //wechat.CheckEcdh = aesKey.ToString(16, 2);
                wechat.AESKey = AES.AESDecrypt(ManualAuth.authParam.session.key, aesKey).ToString(16, 2);

                wechat.baseRequest = wechat.GetBaseRequest("49aa7db2f4a3ffe0e96218f6b92cde32", wechat.GetAESkey(), (uint)wechat.m_uid, "iPad iPhone OS9.3.3");

                authKey = ManualAuth.authParam.autoAuthKey.buffer;
            }
            else if ((int)ManualAuth.baseResponse.ret == 2)
            {
                MyWxid = ManualAuth.accountInfo.wxid;

                put(ManualAuth.accountInfo.wxid);
                put(ObjToJson2 <MM.AccountInfo>(ManualAuth.accountInfo));
                put(ObjToJson2 <MM.BaseResponse>(ManualAuth.baseResponse));


                //byte[] strECServrPubKey = ManualAuth.authParam.ecdh.ecdhkey.key;
                //var aesKey = OpenSSLNativeClass.ECDH.DoEcdh(713, strECServrPubKey, wechat.pri_key_buf);
                //wechat.CheckEcdh = aesKey.ToString(16, 2);
                //wechat.AESKey = AES.AESDecrypt(ManualAuth.authParam.session.key, aesKey).ToString(16, 2);

                //wechat.baseRequest = wechat.GetBaseRequest("49aa7db2f4a3ffe0e96218f6b92cde32", wechat.GetAESkey(), (uint)wechat.m_uid, "iPad iPhone OS9.3.3");
            }
            else
            {
                put(JsonConvert.SerializeObject(ManualAuth));
            }
        }
예제 #9
0
    //读取一个
    private IEnumerator _LoadSceneFromAssetBundle(string name)
    {
        yield return(new WaitForEndOfFrame());

        string path = "";

                #if !UNITY_EDITOR && UNITY_WEBGL
        path = Path.Combine(Application.streamingAssetsPath, GetPlatformFolderForAssetBundles());
                #elif !UNITY_EDITOR && UNITY_ANDROID
        path = Path.Combine(Application.streamingAssetsPath, GetPlatformFolderForAssetBundles());
                #else
        path = Path.Combine("file://" + Application.streamingAssetsPath, GetPlatformFolderForAssetBundles());
                #endif

        path = path + "/" + name + ".unity3d.data";

        Debug.Log("LoadSceneFromAssetBundle " + path);
        WWW www = new WWW(path);

        while (!www.isDone)
        {
            Debug.Log("download " + www.progress);
            SetProgress("下载资源", www.progress);
            yield return(new WaitForEndOfFrame());
        }

        if (www.error != null)
        {
            Debug.LogError(www.error);
            www.Dispose();
            yield break;
        }

        byte[]      data        = AES.AESDecrypt(www.bytes);
        AssetBundle assetBundle = AssetBundle.LoadFromMemory(data);
        www.Dispose();
        data = null;

        AsyncOperation asyncOp = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(name);
        asyncOp.allowSceneActivation = false;
        while (asyncOp.progress < 0.9f)
        {
            Debug.Log("load scene " + asyncOp.progress);
            SetProgress("加载场景", asyncOp.progress);
            yield return(new WaitForEndOfFrame());
        }
        SetProgress("加载场景", 1);
        yield return(new WaitForEndOfFrame());

        asyncOp.allowSceneActivation = true;

        assetBundle.Unload(false);
        SceneLoadManager.Instance.LoadSceneComplete();

        yield break;
    }
예제 #10
0
        private Task InitAsync()
        {
            Task t = new Task(() =>
            {
                AccountList.Clear();

                this.Invoke(new MethodInvoker(() =>
                {
                    this.ListView.Items.Clear();
                }));

                try
                {
                    foreach (KeyValuePair <string, QDataSection> p in QSettings.Account.Sections)
                    {
                        QDataSection ds  = p.Value;
                        CAccount account = new CAccount()
                        {
                            ID       = p.Key,
                            Platform = AES.AESDecrypt(ds["platform"], Key),
                            Account  = AES.AESDecrypt(ds["account"], Key),
                            Password = AES.AESDecrypt(ds["password"], Key),
                            Remarks  = AES.AESDecrypt(ds["remarks"], Key)
                        };

                        ListViewItem item = new ListViewItem(account.Platform);
                        item.SubItems.Add(account.Account);
                        item.SubItems.Add("不给看");
                        item.SubItems.Add(account.Remarks);
                        item.Tag = p.Key;

                        AccountList.Add(p.Key, account);

                        this.Invoke(new MethodInvoker(() =>
                        {
                            this.ListView.Items.Add(item);
                        }));
                    }
                }
                catch (Exception ex)
                {
                    Qdb.Error(QFrameworkOne.Diagnostics.QDebugErrorType.Fatal, ex.Message, "FrmMain.InitAsync");
                    this.Invoke(new MethodInvoker(() =>
                    {
                        ShowMsg("密码错误!");
                    }));
                }

                //this.Invoke(new MethodInvoker(() => { ShowMsg("双击可以复制密码!"); }));
            });

            t.Start();
            return(t);
        }
예제 #11
0
        public void AESRoundTripTest()
        {
            string orig     = "I like to eat pizza all day long!";
            string password = "******";
            string hash     = PasswordHash.HashPassword(password);

            byte[] key       = PasswordHash.GetDecryptedKey(password, hash);
            byte[] encrypted = AES.AESEncrypt(Encoding.ASCII.GetBytes(orig), key, key, 16);
            string decrypted = Encoding.ASCII.GetString(AES.AESDecrypt(encrypted, key, key, 16));

            Assert.AreEqual(orig, decrypted);
        }
예제 #12
0
 private void btnDecrypt_Click(object sender, EventArgs e)
 {
     try
     {
         byte[] buffer = AES.AESDecrypt(@"d:\encrypt.bin".Reader(), "yuanfeng");
         this.SnapshotImage.Image = new Bitmap(new MemoryStream(buffer));
     }
     catch (Exception exception)
     {
         SimpleConsole.WriteLine("this encrypt data parse is fialed.");
     }
 }
예제 #13
0
    /// <summary>
    /// 导入
    /// </summary>
    /// <returns></returns>
    IEnumerator LoadRes()
    {
        WWW www = WWW.LoadFromCacheOrDownload("file:///" + Application.dataPath + "/Resources/" + "test.assetbundle", 1);

        yield return(www);

        TextAsset txt = www.assetBundle.Load("2222", typeof(TextAsset)) as TextAsset;

        byte[] data    = txt.bytes;
        byte[] newdata = AES.AESDecrypt(data);
        StartCoroutine(LoadBundle(newdata));
    }
예제 #14
0
 /// <summary>
 /// AES解密 先解密后解压
 /// </summary>
 /// <param name="data"></param>
 /// <param name="key"></param>
 /// <returns></returns>
 public static byte[] uncompress_aes(byte[] data, byte[] key)
 {
     try
     {
         data = AES.AESDecrypt(data, key);
         data = ZipUtils.deCompressBytes(data);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
     return(data);
 }
예제 #15
0
    public static byte[] LoadFileDecryptBytes(string path)
    {
        byte[] bytes = null;
        try
        {
            bytes = AES.AESDecrypt(File.ReadAllBytes(path), Application.bundleIdentifier);
        }
        catch (Exception e)
        {
            Util.LogError(e.Message);
        }

        return(bytes);
    }
예제 #16
0
 private static void LoadLocal(string _path)
 {
     using (FileStream fs = new FileStream(_path, FileMode.Open, FileAccess.Read))
     {
         if (fs != null)
         {
             byte[] bytes = new byte[fs.Length];
             fs.Read(bytes, 0, bytes.Length);
             //Debug.Log("encrypt: " + bytes.Length + " code: " + Encoding.UTF8.GetString(bytes));
             GameDataManager.Instance.LoadSaveData(JsonTools.jsonDecode(AES.AESDecrypt(bytes)) as Hashtable);
             fs.Flush();
             fs.Dispose();
             Debug.Log("load data finish");
         }
     }
 }
예제 #17
0
    public IEnumerator LoadRes(string fileName)
    {
        if (!debug)
        {
            string path =
#if UNITY_EDITOR
                "file:///" + UnityEngine.Application.persistentDataPath;
#elif UNITY_IPHONE
                "file:///" + Application.persistentDataPath;
#elif UNITY_ANDROID
                "file:///" + Application.persistentDataPath;
#endif
            path += "/Data/";
            path += fileName;

            WWW www = new WWW(path + ".assetbundle");
            // UnityEngine.Application.persistentDataPath
            yield return(www);

            TextAsset txt     = www.assetBundle.Load(fileName, typeof(TextAsset)) as TextAsset;
            byte[]    data    = txt.bytes;
            byte[]    newdata = AES.AESDecrypt(data);
            // StartCoroutine(LoadBundle(newdata));
            //创建资源
            AssetBundleCreateRequest acr = AssetBundle.CreateFromMemory(newdata);
            yield return(acr);

            AssetBundle assetBundle = acr.assetBundle;
            assetBundle.name = fileName;
            ABS.assetBundleList.Add(assetBundle);
            //www.assetBundle.Unload(false);
            //加载完成事件
            lock (o)//加锁
            {
                tempNum++;
            }

            if (tempNum == total)
            {
                if (OnLoaded != null)
                {
                    OnLoaded(fileName, true, "加载成功了");
                }
            }
        }
    }
예제 #18
0
        public static bool CheckSystemCode()
        {
            string systemCode = CommonConfigurationManager.GetAppConfig("SystemCode");

            if (systemCode.Trim() == "")
            {
                return(false);
            }
            try
            {
                return(AES.AESDecrypt(systemCode).Equals(SystemInformationCode.GetCpuID() + "zhangdahang"));
            }
            catch (Exception ex)
            {
            }
            return(false);
        }
예제 #19
0
        public HttpResponseMessage UpdatePayOrder()
        {
            HttpResponseMessage response = null;
            var result = false;

            try
            {
                PayOrder payOrder = new PayOrder();
                using (var ms = new MemoryStream())
                {
                    HttpContext.Current.Request.GetBufferlessInputStream().CopyTo(ms);
                    if (ms.Length != 0)
                    {
                        var cText = WebCommom.HttpRequestBodyConvertToStr(ms);//密文
                        var pText = AES.AESDecrypt(cText, AESKey);
                        payOrder = JsonConvert.DeserializeObject <PayOrder>(pText);
                    }
                }
                result = payOrderBll.Value.UdpatePayOrder(payOrder);
                #region   如果支付成功则通知店家发货(此处可改为异步处理)
                if (payOrder.TradeStatus == "")
                {
                    for (int i = 0; i < payOrder.Orders.Count; i++)
                    {
                        var storeStaff = storeStaffBll.Value.GetReceiveDeliveryStaff(payOrder.Orders[i].BuyProduct.Store.StoreID);
                        var phoneList  = new List <string>();
                        for (int j = 0; j < storeStaff.Count; j++)
                        {
                            phoneList.Add(storeStaff[j].Phone);
                        }
                        SMS sms = new SMS {
                        };
                        //  sms.ReceiveNo = phoneList;
                        //   sms.MSGContent = "";
                        CommomClass.HttpPost(GlobalDictionary.GetSysConfVal("AccountApiAddr"), JsonConvert.SerializeObject(sms));//通知店铺员工发货
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
            }
            response = WebCommom.GetResponse(result);
            return(response);
        }
예제 #20
0
    public static void DecryptAssetBundle(string abPath, string name, Action <UnityEngine.Object> onLoadedCall)
    {
        //使用AES加密的,解密只能用字节转,然后LoadFromMemory
        //使用FileStream那种的(掺和用)报错: CryptographicException: Padding is invalid and cannot be removed.
        byte[] bytes = File.ReadAllBytes(abPath);
        bytes = AES.AESDecrypt(bytes);
        var myLoadedAssetBundle = AssetBundle.LoadFromMemory(bytes);

        var obj = myLoadedAssetBundle.LoadAsset <GameObject>(name);

        try {
            onLoadedCall(obj);
        }
        catch (System.Exception e) {
            Debug.LogError(e.Message);
        }
        myLoadedAssetBundle.Unload(false);
    }
예제 #21
0
        public HttpResponseMessage CreateOrder()
        {
            List <Order>        resultList = new List <Order>();//创建成功的订单
            HttpResponseMessage response   = null;

            try
            {
                List <Order> list = null;
                using (var ms = new MemoryStream())
                {
                    HttpContext.Current.Request.GetBufferlessInputStream().CopyTo(ms);
                    if (ms.Length != 0)
                    {
                        var cText = WebCommom.HttpRequestBodyConvertToStr(ms); //密文
                        var pText = AES.AESDecrypt(cText, AESKey);             //明文
                        list = JsonConvert.DeserializeObject <List <Order> >(pText);
                    }
                }
                if (list != null)
                {
                    //  ProductStock_Cache p = new ProductStock_Cache();
                    //   var updateResult = p.UdpateStock(0, GetUpdateProdcut(list));//修改结果
                    //   resultList = GetSuccessOrder(updateResult, list);//获取修改成功的订单
                    #region 将订单加入到MQ,订单加入MQ之后则代表创建成功
                    //if (resultList.Count > 0)
                    //{
                    //    YunXiu.Commom.MQ.MSMQ mq = new YunXiu.Commom.MQ.MSMQ();
                    //    mq.MSMQIP = "192.168.9.32";
                    //    mq.MSMQName = "OrderQueue";
                    //    mq.MSG = JsonConvert.SerializeObject(resultList);
                    //    mq.SendToMSMQ();
                    //}
                    #endregion
                }
            }
            catch (Exception ex)
            {
            }
            var responseCText = AES.AESEncrypt(JsonConvert.SerializeObject(resultList), AESKey);//结果密文
            response = WebCommom.GetResponse(responseCText);
            return(response);
        }
예제 #22
0
    public byte[] Decode(byte[] buf)
    {
        byte[] body = new byte[buf.Length - HEADER_LENGTH];

        for (int i = 0; i < body.Length; i++)
        {
            body[i] = buf[i + HEADER_LENGTH];
        }

        byte[] data = body;
        if (isEncrypt)
        {
            data = AES.AESDecrypt(body);
        }
        if (isCompress)
        {
            data = ZlibMgr.deCompressBytes(data);
        }
        return(data);
        //return new Package(type, body);
    }
예제 #23
0
    public static IEnumerator AsyncLoad(string abPath, string name, Action <UnityEngine.Object> onLoadedCall)
    {
        byte[] bytes = File.ReadAllBytes(abPath);
        bytes = AES.AESDecrypt(bytes);
        var bundleLoadRequest = AssetBundle.LoadFromMemoryAsync(bytes);

        yield return(bundleLoadRequest);

        var myLoadedAssetBundle = bundleLoadRequest.assetBundle;
        var assetLoadRequest    = myLoadedAssetBundle.LoadAssetAsync(name);

        yield return(assetLoadRequest);

        try {
            onLoadedCall(assetLoadRequest.asset);
        }
        catch (System.Exception e) {
            Debug.LogError(e.Message);
        }
        myLoadedAssetBundle.Unload(false);
    }
예제 #24
0
 private void bt_OK_Click(object sender, EventArgs e)
 {
     try
     {
         //string mechineCode = "BFEBFBFF000806EA";
         string mechineCode = SystemInformationCode.GetCpuID();
         if (AES.AESDecrypt(textBox2.Text).Equals(mechineCode + "zhangdahang"))
         {
             CommonConfigurationManager.UpdateAppConfig("SystemCode", textBox2.Text);
             this.DialogResult = DialogResult.OK;
         }
         else
         {
             MessageBox.Show("您输入的注册码不正确,请重新输入!");
         }
     }
     catch
     {
         MessageBox.Show("您输入的注册码不正确,请重新输入!");
     }
 }
예제 #25
0
파일: Form1.cs 프로젝트: zhangjanp/WeChatXY
        private void Btn_DataLogin_Click(object sender, EventArgs e)
        {
            var UserLoign = wechat.UserLogin(tb_ToUsername.Text, tb_AtUserlist.Text, tb_Content.Text);


            if (UserLoign.baseResponse.ret == MMPro.MM.RetConst.MM_ERR_IDC_REDIRECT)
            {
                //Console.WriteLine(ManualAuth.dnsInfo.builtinIplist.shortConnectIplist[0].ip);
                //byte[] s = Util.Serialize<MM.BuiltinIP>(ManualAuth.dnsInfo.builtinIplist.shortConnectIplist.shortConnectIplist[1]);
                int len = (int)UserLoign.dnsInfo.builtinIplist.shortconnectIpcount;
                Util.shortUrl = "http://" + UserLoign.dnsInfo.newHostList.list[1].substitute;
                Btn_DataLogin_Click(Btn_DataLogin, new EventArgs());
            }
            else if (UserLoign.baseResponse.ret == MMPro.MM.RetConst.MM_OK)
            {
                MyWxid = UserLoign.accountInfo.wxid;

                put(UserLoign.accountInfo.wxid);
                put(ObjToJson2 <MM.AccountInfo>(UserLoign.accountInfo));
                put(ObjToJson2 <MM.BaseResponse>(UserLoign.baseResponse));


                byte[] strECServrPubKey = UserLoign.authParam.ecdh.ecdhkey.key;
                byte[] aesKey           = new byte[16];
                Xcode.ComputerECCKeyMD5(strECServrPubKey, 57, wechat.pri_key_buf, 328, aesKey);
                //var aesKey = OpenSSLNativeClass.ECDH.DoEcdh(ManualAuth.authParam.ecdh.nid, strECServrPubKey, wechat.pri_key_buf);
                //wechat.CheckEcdh = aesKey.ToString(16, 2);
                wechat.AESKey = AES.AESDecrypt(UserLoign.authParam.session.key, aesKey).ToString(16, 2);

                //wechat.baseRequest = wechat.GetBaseRequest(wechat.devicelId, wechat.AESKey.ToByteArray(16, 2), (uint)wechat.m_uid, "iMac iPhone OS9.3.3");

                authKey = UserLoign.authParam.autoAuthKey.buffer;
                put(JsonConvert.SerializeObject(UserLoign.authParam));
            }
            else
            {
                put(JsonConvert.SerializeObject(UserLoign.baseResponse));
            }
        }
예제 #26
0
        public ConfigManager()
        {
            try
            {
                if (!Directory.Exists(defaultPath))
                {
                    Directory.CreateDirectory(defaultPath);
                }
            }
            catch (Exception exception) { throw new Exception("The set path is invalid.", exception); }

            fileName = Path.Combine(defaultPath, fileName);

            if (File.Exists(fileName))
            {
                sourceBuffer = File.ReadAllBytes(fileName);

                if (sourceBuffer != null && sourceBuffer.Length > 0)
                {
                    sourceBuffer = AES.AESDecrypt(sourceBuffer, "yuanfeng");
                }
            }
        }
예제 #27
0
        /// <summary>
        /// Открывает существующий файл SavePass
        /// </summary>
        /// <param name="filename">имя файла</param>
        /// <param name="password">пароль</param>
        public void Open(string filename, string password)
        {
            FileName = filename;
            Password = password;

            using (Stream stream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite))
            {
                using (BinaryReader binrd = new BinaryReader(stream))
                {
                    uint   baseSignature    = binrd.ReadUInt32();
                    uint   versionSignature = binrd.ReadUInt32();
                    byte[] masterSeed       = binrd.ReadBytes(8);
                    _header = new Header(baseSignature, versionSignature, masterSeed);
                    byte[] jsonEncrypted = binrd.ReadBytes((int)(stream.Length - stream.Position));
                    byte[] jsonDecrypted;
                    try
                    {
                        jsonDecrypted = AES.AESDecrypt(jsonEncrypted, Encoding.Unicode.GetBytes(Password), masterSeed);
                    }
                    catch (System.Security.Cryptography.CryptographicException)
                    {
                        throw new WrongPasswordException();
                    }
                    using (MemoryStream ms = new MemoryStream(jsonDecrypted))
                    {
                        try
                        {
                            Root = (Root)_jsonFormatter.ReadObject(ms);
                        }
                        catch (Exception)
                        {
                            throw new FileCorruptException();
                        }
                    }
                }
            }
        }
        public MessageBase DecodeContent(ProtocolEnum proto, byte[] bytes, int offset, int bodyCount)
        {
            if (bodyCount <= 0)
            {
                Debug.LogError($"协议解析出错,数据长度为0");
                return(null);
            }

            try
            {
                byte[] newBytes = new byte[bodyCount];
                Array.Copy(bytes, offset, newBytes, 0, bodyCount);
                string secretKey = Consts.SecretKey;
                if (proto == ProtocolEnum.MessageSecret)
                {
                    secretKey = Consts.PublicKey;
                }
                newBytes = AES.AESDecrypt(newBytes, secretKey);
                using (var memory = new MemoryStream(newBytes, 0, newBytes.Length))
                {
                    if (!_protocolTypeDict.ContainsKey(proto))
                    {
                        Debug.LogError($"无该协议解析:{proto}");
                        return(null);
                    }
                    Type t = _protocolTypeDict[proto];

                    return((MessageBase)Serializer.NonGeneric.Deserialize(t, memory));
                }
            }
            catch (Exception ex)
            {
                Debug.LogError("协议解密出错:" + ex.ToString());
                return(null);
            }
        }
예제 #29
0
        static void AEStest()
        {
            BufferFormat fan = new BufferFormat(1000, new FDataExtraHandle((o) =>
            {
                return(AES.AESEncrypt(o, AESkeys, "hello wordhello wordhello wordhello wordhello wordhello wordhello wordhello wordhello wordhello wordhello wordhello wordhello wordhello word"));
            }));

            fan.AddItem(true);
            fan.AddItem("abc");
            fan.AddItem(123);

            byte[] data = fan.Finish();


            ReadBytes read = new ReadBytes(data, 4, -1, new RDataExtraHandle((o) =>
            {
                return(AES.AESDecrypt(o, AESkeys, "hello wordhello wordhello wordhello wordhello wordhello wordhello wordhello wordhello wordhello wordhello wordhello wordhello wordhello word"));
            }));

            int    lengt;
            int    cmd;
            bool   var1;
            string var2;
            int    var3;

            if (read.IsDataExtraSuccess &&
                read.ReadInt32(out lengt) &&
                lengt == read.Length &&
                read.ReadInt32(out cmd) &&
                read.ReadBoolean(out var1) &&
                read.ReadString(out var2) &&
                read.ReadInt32(out var3))
            {
                Console.WriteLine("This AES-> Length:{0} Cmd:{1} var1:{2} var2:{3} var3:{4}", lengt, cmd, var1, var2, var3);
            }
        }
예제 #30
0
 /// <summary>
 /// //AES解密 只解密
 /// </summary>
 /// <param name="data"></param>
 /// <param name="key"></param>
 /// <returns></returns>
 public static byte[] nouncompress_aes(byte[] data, byte[] key)
 {
     data = AES.AESDecrypt(data, key);
     //data = ZipUtils.deCompressBytes(data);
     return(data);
 }