public static ParsingState TryParseSettings(LocalStorage storage) { try { var parsingState = storage._fileIO.TryReadFile("settings", FilePath.Base, out FileReadDescriptor file); if (parsingState.NotSuccessful()) { return(parsingState); } DataStream stream = file.DataStream; byte[] salt = stream.ReadByteArray(); byte[] settingsEncrypted = stream.ReadByteArray(); if (salt.Length != Constants.LocalEncryptSaltSize) { return(ParsingState.InvalidData); } AuthKey settingsKey = AuthKey.CreateLocalKey(null, salt); if (!settingsKey.TryDecryptLocal(settingsEncrypted, out byte[] settingsData))
public static ParsingState TryParseMap(LocalStorage storage, string passcode) { try { var parsingState = storage._fileIO.TryReadFile("map", FilePath.User, out FileReadDescriptor file); if (parsingState.NotSuccessful()) { return(parsingState); } storage.ClientVersion = file.Version; DataStream stream = file.DataStream; byte[] salt = stream.ReadByteArray(); byte[] keyEncrypted = stream.ReadByteArray(); byte[] mapEncrypted = stream.ReadByteArray(); if (salt.Length != Constants.LocalEncryptSaltSize) { return(ParsingState.InvalidData); } byte[] passcodeBytes = passcode == null ? null : Encoding.UTF8.GetBytes(passcode); AuthKey passKey = AuthKey.CreateLocalKey(passcodeBytes, salt); if (!passKey.TryDecryptLocal(keyEncrypted, out byte[] keyData))