public bool IsValidFile(string pKey) { bool result = false; //if (SettingsApp.DeveloperMode) return true; if (File.Exists(pKey)) { //Get In Memory values string md5Encryptd = this[pKey].Md5Encrypted; string md5FromMem = this[pKey].Md5; //get Fresh Hash string md5FromFile = FrameworkUtils.MD5HashFile(pKey); //Check if created are equal to encrypted in memory, if false user change file after BootStrap bool valid = SaltedString.ValidateSaltedString(md5Encryptd, md5FromFile); //Update Protected File this[pKey].Md5 = md5FromFile; this[pKey].Valid = valid; //debug if (_debug) { _log.Debug(string.Format("IsValidFile md5FromMem: [{0}], md5FromFile: [{1}], valid: [{2}]", md5FromMem, md5FromFile, valid)); } //Assign to final Result result = valid; } return(result); }
//Used by Application, to check if files are valid, create from Dictionary(File) public ProtectedFile(string pFilePath, string pMd5Salted) { _md5 = FrameworkUtils.MD5HashFile(pFilePath); _md5Salted = pMd5Salted; _valid = (SaltedString.ValidateSaltedString(pMd5Salted, _md5)); }
//Create ProtectedFile Properties from FilePath, used by Developer, when recreate FileCSV public ProtectedFile(string pFilePath) { _md5 = FrameworkUtils.MD5HashFile(pFilePath); _md5Salted = SaltedString.GenerateSaltedString(_md5); _valid = true; }