Exemplo n.º 1
0
    public static void SaveAESKeyAndIV(byte[] Key, byte[] IV)
    {
        BinaryFormatter formatter = new BinaryFormatter();

        //Android
        string path = Application.persistentDataPath + "/AESKeyAndIV.fun";

        Debug.Log(path);
        FileStream fs = new FileStream(path, FileMode.Create);

        AESKeyAndIV data = new AESKeyAndIV(Key, IV);

        formatter.Serialize(fs, data);
        fs.Close();
    }
Exemplo n.º 2
0
    public static AESKeyAndIV LoadAESKeyAndIV()
    {
        string path = Application.persistentDataPath + "/AESKeyAndIV.fun";

        Debug.Log(path);
        if (File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      fs        = new FileStream(path, FileMode.Open);

            AESKeyAndIV data = formatter.Deserialize(fs) as AESKeyAndIV;
            fs.Close();

            return(data);
        }
        else
        {
            //Debug.LogError("Save File not found in " + path);
            return(null);
        }
    }
Exemplo n.º 3
0
    public User()
    {
        using (Aes aesAlg = Aes.Create())
        {
            keyIV = SaveSystem.LoadAESKeyAndIV();

            if (SaveSystem.LoadAESKeyAndIV() != null)
            {
                aesAlg.Key = keyIV.Key;
                aesAlg.IV  = keyIV.IV;
            }
            else if (SaveSystem.LoadAESKeyAndIV() == null)
            {
                keyIV = new AESKeyAndIV(aesAlg.Key, aesAlg.IV);
                SaveSystem.SaveAESKeyAndIV(aesAlg.Key, aesAlg.IV);
            }

            // User Info
            //UserGold = 1000;
            //UserJam = 10;
            //TutorialStoyClear = new bool[(int)eStoryState.END];
            //for (int i = 0; i < (int)eStoryState.END; i++)
            //{
            //    TutorialStoyClear[i] = false;
            //}
            UserGold           = AESSecurity.Encrypt_ToBytes_Aes <int>(1000, aesAlg.Key, aesAlg.IV);
            UserJam            = AESSecurity.Encrypt_ToBytes_Aes <int>(10, aesAlg.Key, aesAlg.IV);
            TutorialStoryClear = new List <byte[]>();
            for (int i = 0; i < (int)eStoryState.END; i++)
            {
                TutorialStoryClear.Add(AESSecurity.Encrypt_ToBytes_Aes <bool>(false, aesAlg.Key, aesAlg.IV));
            }

            // Hero Info

            /*
             * UserAbilityLevel = new int[(int)eHeroAbilityKind.END];
             * for (int i = 0; i < (int)eHeroAbilityKind.END; i++)
             * {
             *  UserAbilityLevel[i] = 1;
             * }
             *
             * UserSkillLevel = new int[(int)eHeroAbilityKind.END];
             * for (int i = 0; i < (int)eHeroSkillKind.END; i++)
             * {
             *  UserSkillLevel[i] = 1;
             * }
             *
             * UserBuildingLevel = new int[(int)eHeroAbilityKind.END];
             * for (int i = 0; i < (int)eBuildingKind.END; i++)
             * {
             *  UserBuildingLevel[i] = 1;
             * }
             *
             * UserIsUnlockSkill = new bool[(int)eHeroSkillKind.END];
             * for (int i = 0; i < (int)eHeroSkillKind.END; i++)
             * {
             *  // 임시로 스매시 스킬 언락
             *  if (i == 0)
             *  {
             *      UserIsUnlockSkill[i] = true;
             *  }
             *  else
             *  {
             *      UserIsUnlockSkill[i] = false;
             *  }
             * }
             */
            UserAbilityLevel = new List <byte[]>();
            for (int i = 0; i < (int)eHeroAbilityKind.END; i++)
            {
                UserAbilityLevel.Add(AESSecurity.Encrypt_ToBytes_Aes <int>(1, aesAlg.Key, aesAlg.IV));
            }
            UserSkillLevel = new List <byte[]>();
            for (int i = 0; i < (int)eHeroSkillKind.END; i++)
            {
                UserSkillLevel.Add(AESSecurity.Encrypt_ToBytes_Aes <int>(1, aesAlg.Key, aesAlg.IV));
            }
            UserBuildingLevel = new List <byte[]>();
            for (int i = 0; i < (int)eBuildingKind.END; i++)
            {
                UserBuildingLevel.Add(AESSecurity.Encrypt_ToBytes_Aes <int>(1, aesAlg.Key, aesAlg.IV));
            }
            UserIsUnlockSkill = new List <byte[]>();
            for (int i = 0; i < (int)eHeroSkillKind.END; i++)
            {
                if (i == 0)
                {
                    UserIsUnlockSkill.Add(AESSecurity.Encrypt_ToBytes_Aes <bool>(true, aesAlg.Key, aesAlg.IV));
                }
                UserIsUnlockSkill.Add(AESSecurity.Encrypt_ToBytes_Aes <bool>(false, aesAlg.Key, aesAlg.IV));
            }

            // Stage Info

            /*
             * UserIsStageOpen = new bool[(int)eStageKind.END];
             * {
             *  for (int i = 0; i < (int)eStageKind.END; i++)
             *  {
             *      if (i == 0)
             *      {
             *          UserIsStageOpen[i] = true;  // Stage1은 처음부터 열려있다.
             *      }
             *      else if (i == 1)
             *      {
             *          UserIsStageOpen[i] = false;  // 임시로 열어둠
             *      }
             *      else
             *      {
             *          UserIsStageOpen[i] = false;
             *      }
             *  }
             * }
             *
             * UserStageBossShow = new bool[(int)eStageKind.END];
             * for (int i = 0; i < (int)eStageKind.END; i++)
             * {
             *  //UserStageBossShow[i] = false;
             *  if (i == 0)
             *  {
             *      UserStageBossShow[i] = false;    // 임의로 열어놓음
             *  }
             *  else
             *  {
             *      UserStageBossShow[i] = false;
             *  }
             * }
             *
             * UserStageBossClear = new bool[(int)eStageKind.END];
             * for (int i = 0; i < (int)eStageKind.END; i++)
             * {
             *  UserStageBossClear[i] = false;
             * }
             *
             * UserStageBossTime = new string[(int)eStageKind.END];
             * for (int i = 0; i < (int)eStageKind.END; i++)
             * {
             *  // 현재 시간 - 1Day 으로 저장
             *  UserStageBossTime[i] = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
             * }
             */

            UserIsStageOpen = new List <byte[]>();
            for (int i = 0; i < (int)eStageKind.END; i++)
            {
                if (i == 0)
                {
                    UserIsStageOpen.Add(AESSecurity.Encrypt_ToBytes_Aes <bool>(true, aesAlg.Key, aesAlg.IV));
                }
                else
                {
                    UserIsStageOpen.Add(AESSecurity.Encrypt_ToBytes_Aes <bool>(false, aesAlg.Key, aesAlg.IV));
                }
            }
            UserStageBossShow = new List <byte[]>();
            for (int i = 0; i < (int)eStageKind.END; i++)
            {
                UserStageBossShow.Add(AESSecurity.Encrypt_ToBytes_Aes <bool>(false, aesAlg.Key, aesAlg.IV));
            }
            UserStageBossClear = new List <byte[]>();
            for (int i = 0; i < (int)eStageKind.END; i++)
            {
                UserStageBossClear.Add(AESSecurity.Encrypt_ToBytes_Aes <bool>(false, aesAlg.Key, aesAlg.IV));
            }
            UserStageBossTime = new List <byte[]>();
            for (int i = 0; i < (int)eStageKind.END; i++)
            {
                UserStageBossTime.Add(AESSecurity.Encrypt_ToBytes_Aes <string>(
                                          DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss"), aesAlg.Key, aesAlg.IV));
            }

            // Option Info
            BGMVolume = 1.0f;
            BGMMute   = false;
            SFxVolume = 1.0f;
            SFxMute   = false;
        }
    }