/// <summary> /// Reads the information from the given .ab file /// </summary> /// <param name="path">The path of the .ab file</param> /// <param name="password">The password to use</param> /// <returns>The BackupFileInfo instance</returns> public static BackupFileInfo FromFile(string path, string password = "******") { BackupFileInfo result = new BackupFileInfo(); Java.Update(); string output = Java.RunJarWithOutput(ResourceManager.abePath, new string[] { "-debug", "info", "\"" + path + "\"", password }); result.magic = output.Between("Magic: ", "\r\n"); result.algorithm = output.Between("Algorithm: ", "\r\n"); result.compressed = (output.Between("Compressed: ", "\r\n").Contains("1") ? true : false); result.version = (output.Between("Version: ", "\r\n").Contains("1") ? BackupFileVersion.Version1 : BackupFileVersion.Version2); BackupFileEncryptedInformation ei = new BackupFileEncryptedInformation(); if (!output.Contains("Exception") && output.Contains("IV: ")) { ei.iV = output.Between("IV: ", "\r\n"); ei.keyBytes = output.Between("key bytes: ", "\r\n"); ei.keyFormat = output.Between("Key format: ", "\r\n"); ei.mK = output.Between("MK: ", "\r\n"); ei.mKAsString = output.Between("MK as string: ", "\r\n"); ei.mKChecksum = output.Between("MK checksum: ", "\r\n"); ei.saltBytes = output.Between("salt bytes: ", "\r\n"); } result.encrytedInformation = ei; return(result); }
/// <summary> /// Reads the information from the given .ab file /// </summary> /// <param name="path">The path of the .ab file</param> /// <param name="password">The password to use</param> /// <returns>The BackupFileInfo instance</returns> public static BackupFileInfo FromFile(string path, string password = "******") { BackupFileInfo result = new BackupFileInfo(); Java.Update(); string output = Java.RunJarWithOutput(ResourceManager.abePath, new string[] { "-debug", "info", "\"" + path + "\"", password }); result.magic = output.Between("Magic: ", "\r\n"); result.algorithm = output.Between("Algorithm: ", "\r\n"); result.compressed = (output.Between("Compressed: ", "\r\n").Contains("1") ? true : false); result.version = (output.Between("Version: ", "\r\n").Contains("1") ? BackupFileVersion.Version1 : BackupFileVersion.Version2); BackupFileEncryptedInformation ei = new BackupFileEncryptedInformation(); if(!output.Contains("Exception") && output.Contains("IV: ")) { ei.iV = output.Between("IV: ", "\r\n"); ei.keyBytes = output.Between("key bytes: ", "\r\n"); ei.keyFormat = output.Between("Key format: ", "\r\n"); ei.mK = output.Between("MK: ", "\r\n"); ei.mKAsString = output.Between("MK as string: ", "\r\n"); ei.mKChecksum = output.Between("MK checksum: ", "\r\n"); ei.saltBytes = output.Between("salt bytes: ", "\r\n"); } result.encrytedInformation = ei; return result; }
internal BackupFile(string path) { mPassword = "******"; mFilePath = path; mFileInfo = BackupFileInfo.FromFile(path, mPassword); }
/// <summary> /// Set password of the backup file /// </summary> /// <param name="password">The password to set to</param> /// <returns>True if the password is correct</returns> public bool SetPassword(string password) { mFileInfo = BackupFileInfo.FromFile(mFilePath, password); return !mFileInfo.EncryptedInformation.ValuesAreEmpty(); }
/// <summary> /// Set password of the backup file /// </summary> /// <param name="password">The password to set to</param> /// <returns>True if the password is correct</returns> public bool SetPassword(string password) { mFileInfo = BackupFileInfo.FromFile(mFilePath, password); return(!mFileInfo.EncryptedInformation.ValuesAreEmpty()); }