Esempio n. 1
0
    IEnumerator RunUnZipFile()
    {
        yield return(new WaitForEndOfFrame());

        configLoading.SetDescribe(Core.Data.stringManager.getString(9028));
        configLoading.ShowLoading(0);
        string ConfigPath = System.IO.Path.Combine(DeviceInfo.PersistRootPath, "Config.zip");

        MessageDigest_Algorithm.getFileMd5Hash(ConfigPath);

        string[] FileProperties = new string[2];
        //待解压的文件
        FileProperties[0] = ConfigPath;
        //解压后放置的目标目录
        FileProperties[1] = DeviceInfo.PersistRootPath;
        UnZipClass UnZc = new UnZipClass();

        UnZc.UnZip(FileProperties);

        yield return(new WaitForEndOfFrame());

        configLoading.ShowLoading(1);

        yield return(new WaitForEndOfFrame());

        configLoading.gameObject.SetActive(false);
        //解压完成以后读表
        readLocalConfig();
    }
Esempio n. 2
0
    // generate 32bit string
    private string GenerateUniqueIdentify()
    {
        Guid   guid   = Guid.NewGuid();
        string unique = guid.ToString();

        saveToFile(unique);
        //md5 hash
        unique = MessageDigest_Algorithm.getMd5Hash(unique);
        return(unique);
    }
Esempio n. 3
0
    //检查更新配表
    void checkConfig()
    {
                #if UNITY_ANDROID
        if (step == LoginStep.Download_ERROR || step == LoginStep.None || step == LoginStep.Prepare_Config)
        {
                #else
        if (step == LoginStep.Download_ERROR || step == LoginStep.None)
        {
                #endif
            MobilePhoneInfo PhoneInfo = Core.Data.extensionManager.iPhoneInfo;
            if (PhoneInfo != null)
            {
                /*
                 * Debug.Log("appCurName="+PhoneInfo.appCurName);
                 * Debug.Log("PhoneInfo="+PhoneInfo.appCurVersion);
                 * Debug.Log("appCurVersionNum="+PhoneInfo.appCurVersionNum);
                 * Debug.Log("deviceName="+PhoneInfo.deviceName);
                 * Debug.Log("identifierNumber="+PhoneInfo.identifierNumber);
                 * Debug.Log("phoneVersion="+PhoneInfo.phoneVersion);
                 * Debug.Log("phoneModel="+PhoneInfo.phoneModel);
                 * Debug.Log("userPhoneName="+PhoneInfo.userPhoneName);
                 * Debug.Log("localPhoneModel="+PhoneInfo.localPhoneModel);
                 * Debug.Log("appCurVersionNum="+PhoneInfo.appCurVersionNum);
                 */
            }

            //开始检测要不要下载
            step = LoginStep.CheckConfig_Start;

            //MD5  --> config.zip
            string ConfigMD5  = "";
            string ConfigPath = System.IO.Path.Combine(DeviceInfo.PersistRootPath, "Config.zip");
            if (System.IO.File.Exists(ConfigPath))
            {
                ConfigMD5 = MessageDigest_Algorithm.getFileMd5Hash(ConfigPath);
            }

            ConsoleEx.DebugLog(" ZIPFILE Path= " + ConfigPath + " md5= " + ConfigMD5);

            CMSHttpTask task = new CMSHttpTask(ThreadType.MainThread, TaskResponse.Default_Response);
            task.AppendCommonParam(RequestType.UPDATE_RESOURCES, new CheckConfig((int)RequestType.UPDATE_RESOURCES, ConfigMD5, SoftwareInfo.VersionCode.ToString()), "http://114.215.183.29/gs/ms/index.php/configure/check");
            task.ErrorOccured   += HttpResp_Error;
            task.afterCompleted += HttpResp_UI;
            //then you should dispatch to a real handler
            task.DispatchToRealHandler();
        }
        else if (step == LoginStep.ReadConfig_OK)
        {
            readCompleted();
        }
    }
Esempio n. 4
0
        static void ZipMD5()
        {
            string ConfigPath = System.IO.Path.Combine(Application.streamingAssetsPath, "Config.zip");
            //string ConfigPath = System.IO.Path.Combine(DeviceInfo.PersistRootPath,"Config.zip");
            string ConfigMD5 = MessageDigest_Algorithm.getFileMd5Hash(ConfigPath);

            if (string.IsNullOrEmpty(ConfigMD5))
            {
                EditorUtility.DisplayDialog("Config.zip MD5", "can't find Config.zip", "OK");
            }
            else
            {
                EditorUtility.DisplayDialog("Config.zip MD5", ConfigMD5, "OK");
            }
        }
Esempio n. 5
0
    public static string _________________________(string a, string b, string c, string d, string e)
    {
        string _________ = null;

        char[]   _  = MessageDigest_Algorithm.getMd5Hash(a + b + c + d + e).ToCharArray();
        UInt16[] __ = new UInt16[8];

        for (int ____________ = 0; ____________ < 8; ++____________)
        {
            StringBuilder ___ = new StringBuilder();
            ___.Append(_[____________ * 4]).Append(_[____________ * 4 + 1]).Append(_[____________ * 4 + 2]).Append(_[____________ * 4 + 3]);
            UInt16 ___________ = UInt16.Parse(___.ToString(), System.Globalization.NumberStyles.HexNumber);
            __[____________] = ___________;
        }

        char[] ____ = new char[________________];
        for (int ____________ = 0; ____________ < ________________; ++____________)
        {
            int _____________ = NetRandom.Instance.Next(16);

            ____[____________] = ______________[_____________];
        }

        string _____ = Convert.ToString(____[_________________ - 1]) + Convert.ToString(____[__________________ - 1]) + Convert.ToString(____[___________________ - 1])
                       + Convert.ToString(____[____________________ - 1]);

        UInt16 ______ = UInt16.Parse(_____, System.Globalization.NumberStyles.HexNumber);

        UInt16 _______ = 0;

        foreach (UInt16 __________ in __)
        {
            unchecked {
                _______ = (UInt16)(_______ + (__________ ^ ______));
            };
        }


        UInt16Converter ________ = _______;

        ____[_____________________ - 1]    = _______________[________.__________________________].ToCharArray()[0];
        ____[______________________ - 1]   = _______________[________.__________________________].ToCharArray()[1];
        ____[_______________________ - 1]  = _______________[________._________________________].ToCharArray()[0];
        ____[________________________ - 1] = _______________[________._________________________].ToCharArray()[1];

        _________ = new string(____);
        return(_________);
    }
Esempio n. 6
0
    void OnGUI()
    {
        if (GUI.Button(new Rect(400, 130, 100, 50), "ZipClass"))
        {
            string [] FileProperties = new string[2];
            //待压缩文件目录
            FileProperties[0] = @"/Users/jiangcheng/Desktop/ziptest";
            //压缩后的目标文件
            FileProperties[1] = @"/Users/jiangcheng/Desktop/a.zip";
            ZipClass Zc = new ZipClass();
            Zc.ZipFileMain(FileProperties);

            //Debug.Log(DeviceInfo.StreamingPath);
//			ZipClass Zc=new ZipClass();
//			Zc.ZipFile(@"/Users/jiangcheng/Desktop/ziptest",@"/Users/jiangcheng/Desktop/a.zip",6,2048);
        }

        if (GUI.Button(new Rect(400, 200, 100, 50), "UnZipClass"))
        {
            string ConfigPath = System.IO.Path.Combine(DeviceInfo.StreamingPath, "Config.zip");
            //string ConfigMD5 = MessageDigest_Algorithm.getFileMd5Hash(ConfigPath);
            Debug.Log(Core.Data.guideManger.getBasePath());

            string [] FileProperties = new string[2];
            //待解压的文件
            FileProperties[0] = ConfigPath;
            //解压后放置的目标目录
            FileProperties[1] = Core.Data.guideManger.getBasePath();
            UnZipClass UnZc = new UnZipClass();
            UnZc.UnZip(FileProperties);
        }

        if (GUI.Button(new Rect(400, 270, 100, 50), "GetMD5"))
        {
            string ConfigPath = System.IO.Path.Combine(DeviceInfo.StreamingPath, "Config.zip");
            string ConfigMD5  = MessageDigest_Algorithm.getFileMd5Hash(ConfigPath);
            Debug.Log(ConfigMD5);
        }

        if (GUI.Button(new Rect(400, 340, 100, 50), "DownLoad"))
        {
            string ConfigPath = System.IO.Path.Combine(DeviceInfo.StreamingPath, "Config.zip");
            string ConfigMD5  = MessageDigest_Algorithm.getFileMd5Hash(ConfigPath);
            test_DownloadResource(ConfigMD5);
        }
    }
Esempio n. 7
0
    private string ReadUniqueIdentify()
    {
        MemoryStream ByteBuilder = new MemoryStream();

        byte[] content = new byte[UNIQUELENGTH];
        using (FileStream fs = File.Open(UNIQUE_PATH, FileMode.Open)) {
            int readed = 0;
            while ((readed = fs.Read(content, 0, UNIQUELENGTH)) > 0)
            {
                ByteBuilder.Append(content, readed);
            }
        }
        UTF8Encoding utf8   = new UTF8Encoding(true);
        string       Unique = utf8.GetString(ByteBuilder.ToArray());

        //md5 hash
        Unique = MessageDigest_Algorithm.getMd5Hash(Unique);
        return(Unique);
    }
Esempio n. 8
0
 //获取文件MD5码
 public static string GetMD5(string filePath)
 {
     return(MessageDigest_Algorithm.getFileMd5Hash(filePath));
 }