/// <summary> /// 暗号化後に圧縮. /// </summary> private static void CreatePackage(string filePath) { var aesManaged = AESExtension.CreateAesManaged(AssetBundleManager.AesPassword); try { // 作成する圧縮ファイルのパス var compressedPackage = filePath + AssetBundleManager.PackageExtension; // 圧縮するデータをすべて読み取る. using (var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { var data = new byte[fileStream.Length]; fileStream.Read(data, 0, data.Length); // 暗号化して書き込み. File.WriteAllBytes(compressedPackage, data.Encrypt(aesManaged)); } // 元のファイル削除. File.Delete(filePath); } catch (Exception exception) { Debug.LogException(exception); } }
private void SetDevelopmentText(string text) { if (aesManaged == null) { aesManaged = AESExtension.CreateAesManaged(AESKey, AESIv); } developmentText = text == null ? string.Empty : text.Encrypt(aesManaged); }
//----- property ----- //----- method ----- public string GetDevelopmentText() { if (aesManaged == null) { aesManaged = AESExtension.CreateAesManaged(AESKey, AESIv); } if (developmentText == null) { return(string.Empty); } return(string.Format("{0}{1}", DevelopmentMark, developmentText.Decrypt(aesManaged))); }
void OnEnable() { if (aesManaged == null) { aesManaged = AESExtension.CreateAesManaged(AESKey, AESIv); } var instance = target as Memo; var memo = Reflection.GetPrivateField <Memo, string>(instance, "memo"); if (!string.IsNullOrEmpty(memo)) { text = memo.Decrypt(aesManaged); } }
/// <summary> /// 初期設定をします。 /// Initializeで設定した値はstatic変数として保存されます。 /// </summary> /// <param name="installPath"></param> /// <param name="localMode"><see cref="installPath"/>のファイルからアセットを取得</param> /// <param name="simulateMode">AssetDataBaseからアセットを取得(EditorOnly)</param> /// <param name="cryptPassword">暗号化用パスワード(16文字) AssetManageConfig.assetのCryptPasswordと一致している必要があります</param> public void Initialize(string installPath, bool localMode = false, bool simulateMode = false, string cryptPassword = DefaultPassword) { if (isInitialized) { return; } this.installPath = installPath; this.localMode = localMode; this.simulateMode = Application.isEditor && simulateMode; downloadQueueing = new Dictionary <string, IObservable <string> >(); assetBundleCache = new Dictionary <string, CachedInfo>(); cacheQueueing = new Dictionary <string, IObservable <Tuple <AssetBundle, string> > >(); downloadingErrors = new Dictionary <string, string>(); assetInfosByAssetBundleName = new Dictionary <string, AssetInfo[]>(); dependencies = new Dictionary <string, string[]>(); aesManaged = AESExtension.CreateAesManaged(cryptPassword); BuildAssetInfoTable(); isInitialized = true; }
/// <summary> /// パッケージファイル化(暗号化). /// </summary> private static void CreatePackage(string exportPath, string assetBundlePath, AssetInfo assetInfo, string password) { var aesManaged = AESExtension.CreateAesManaged(password); // ※ パッケージファイルが存在する時は内容に変更がない時なのでそのままコピーする. try { // アセットバンドルファイルパス. var assetBundleFilePath = PathUtility.Combine(assetBundlePath, assetInfo.AssetBundle.AssetBundleName); // パッケージファイル名. var packageFileName = Path.ChangeExtension(assetInfo.FileName, AssetBundleManager.PackageExtension); // 作成する圧縮ファイルのパス. var packageFilePath = PathUtility.Combine(assetBundlePath, packageFileName); // 作成したファイルの出力先. var packageExportPath = PathUtility.Combine(exportPath, packageFileName); byte[] data = null; // 読み込み. using (var fileStream = new FileStream(assetBundleFilePath, FileMode.Open, FileAccess.Read)) { data = new byte[fileStream.Length]; fileStream.Read(data, 0, data.Length); } // 暗号化して書き込み. if (File.Exists(packageFilePath)) { File.Delete(packageFilePath); } using (var fileStream = new FileStream(packageFilePath, FileMode.Create, FileAccess.Write)) { data = data.Encrypt(aesManaged); fileStream.Write(data, 0, data.Length); } // ディレクトリ作成. var directory = Path.GetDirectoryName(packageExportPath); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } File.Copy(packageFilePath, packageExportPath, true); File.Delete(packageFilePath); } catch (Exception exception) { Debug.LogException(exception); } }
//----- property ----- //----- method ----- protected override void OnCreate() { aesManaged = AESExtension.CreateAesManaged(AESKey, AESIv); filePathDictionary = new Dictionary <Type, string>(); }