private void DecryptNoteBody(DBNote note) { if (!note.IsEncypted) return; note.Decrypt (User, encryptionMasterKey); note.IsEncypted = false; }
public static void Decrypt(this DBNote note, DBUser user, string master_key) { var per_note_key = note.EncryptedKey.DecryptWithKey(master_key, user.MasterKeySalt); byte[] b_key = per_note_key.ToByteArray(); byte[] b_note_text = note.Text.ToByteArray(); note.Text = user.DecryptUnicodeString(b_key, b_note_text); }
public void NotesTableCellSelected(object sender, SelectedItemChangedEventArgs e) { // deselect _notesTable.SelectedItem = null; // show note-specific page DBNote note = e.SelectedItem as DBNote; if (note != null) { var notePage = new NotePage(); notePage.noteID = note.ID; Navigation.PushAsync(notePage, true); } }
protected override void OnAppearing() { base.OnAppearing(); if (noteID >= 0) { var _ = DataManager.SharedInstace.GetNoteAsync(noteID).ContinueWith(delegate(Task <DBNote> task) { Device.BeginInvokeOnMainThread(delegate() { var note = task.Result; _currentNote = note; _contentStackView.BindingContext = note; _imageView.Source = null; _imageView.Source = note.ImageURLString; _bottomBarCreatePDFButton.IsEnabled = App.PDFHelper.IsAvailable(); }); }); } }
private string GetEncryptedNoteKey(DBNote note) { // re-use the same key when saving a note string encrypted_per_note_key; var saved_note = db.FirstOrDefault<DBNote> (n => n.CompoundPrimaryKey == note.CompoundPrimaryKey); if (saved_note != null) { encrypted_per_note_key = saved_note.EncryptedKey; } else { // new note, generate a new key var rng = new RNGCryptoServiceProvider (); encrypted_per_note_key = rng.Create256BitLowerCaseHexKey ().EncryptWithKey (encryptionMasterKey, User.MasterKeySalt); } return encrypted_per_note_key; }
private void EncryptNoteBody(DBNote note) { // decrypt the per note key var plaintext_key = note.EncryptedKey.DecryptWithKey (encryptionMasterKey, User.MasterKeySalt); note.IsEncypted = true; note.Text = User.EncryptString (plaintext_key.ToByteArray (), note.Text).ToHexString (); }
protected void SaveDBNote(DBNote db_note) { // archive any previously existing note into its own table // TODO: evaluate how we could re-use the same DBNote table, which will save us // a select + reinsert operation // if (UseHistory) { // var old_note = db.FirstOrDefault<DBNote> (n => n.CompoundPrimaryKey == db_note.CompoundPrimaryKey); // if (old_note != null) { // var archived_note = new DBArchivedNote ().PopulateWith (old_note); // // set the last known revision // // if (Manifest.NoteRevisions.Keys.Contains (db_note.Guid)) { // archived_note.LastSyncRevision = Manifest.NoteRevisions[db_note.Guid]; // } // db.Insert<DBArchivedNote> (archived_note); // } // } // unforunately, we can't know if that note already exist // so we delete any previous incarnations of that note and // re-insert db.Delete<DBNote> (n => n.CompoundPrimaryKey == db_note.CompoundPrimaryKey); db.Insert (db_note); }
void Start() { // Instantiate useSaveLevel = new UseSaveLevel(); dBLevel = new DBLevel(); useLoadLevel = new UseLoadLevel(); useInitLevel = new UseInitLevel(); useCreateNote = new UseCreateNote(); dBNote = new DBNote(); useDeleteNote = new UseDeleteNote(); useAbortLevel = new UseAbortLevel(); useInitSong = new UseInitSong(); dBSong = new DBSong(); useSetSong = new UseSetSong(); useLatencyReset = new UseLatencyReset(); dSLatency = new DSLatency(); useLatency = new UseLatency(); useJukeTime = new UseJukeTime(); conMenuState = new ConMenuState(); conMenuExitGame = new ConMenuExitGame(); conMenuExitEdit = new ConMenuExitEdit(); conMenuExitLatency = new ConMenuExitLatency(); conMenuLatency = new ConMenuLatency(); conMenuGame = new ConMenuGame(); conMenuEdit = new ConMenuEdit(); useNoteKiller = new UseNoteKiller(); conAbortLevel = new ConAbortLevel(); conLoadLevel = new ConLoadLevel(); conSetSong = new ConSetSong(); useHP = new UseHP(); // Update updater.AddIMB(useSaveLevel); updater.AddIMB(useLoadLevel); updater.AddIMB(useInitLevel); updater.AddIMB(useCreateNote); updater.AddIMB(useDeleteNote); updater.AddIMB(useAbortLevel); updater.AddIMB(useInitSong); updater.AddIMB(useSetSong); updater.AddIMB(useLatencyReset); updater.AddIMB(useLatency); updater.AddIMB(useJukeTime); updater.AddIMB(conMenuState); updater.AddIMB(conMenuExitGame); updater.AddIMB(conMenuExitEdit); updater.AddIMB(conMenuExitLatency); updater.AddIMB(conMenuLatency); updater.AddIMB(conMenuGame); updater.AddIMB(conMenuEdit); updater.AddIMB(useNoteKiller); updater.AddIMB(conAbortLevel); updater.AddIMB(conLoadLevel); updater.AddIMB(conSetSong); updater.AddIMB(useHP); // Connect useSaveLevel.modelCrtLevelAction += dBLevel.ReceiveModelCrtLevel; useLoadLevel.modelGetLevelAction += dBLevel.ReceiveModelGetLevel; useInitLevel.modelGetLevelAction += dBLevel.ReceiveModelGetLevel; useCreateNote.modelCrtNoteAction += dBNote.ReceiveModelCrtNote; useDeleteNote.modelDelNoteAction += dBNote.ReceiveModelDelNote; useAbortLevel.modelDelNoteAction += dBNote.ReceiveModelDelNote; useSaveLevel.modelGetNoteAction += dBNote.ReceiveModelGetNote; outCreateNote.modelCrtInsNoteAction += facNote.ReceiveModelCrtInsNote; outDeleteNote.modelDelInsNoteAction += facNote.ReceiveModelDelInsNote; outJukeTime.modelOutJukeTimeAction += outCam.ReceiveModelOutJukeTime; outJukeTime.modelOutJukeTimeAction += inCreateNote.ReceiveModelOutJukeTime; outJukeTime.modelOutJukeTimeAction += inDeleteNote.ReceiveModelOutJukeTime; useInitSong.modelCrtSongAction += dBSong.ReceiveModelCrtSong; useSetSong.modelGetSongAction += dBSong.ReceiveModelGetSong; useLatencyReset.modelSetLatencyAction += dSLatency.ReceiveModelSetLatency; useLatency.modelSetLatencyAction += dSLatency.ReceiveModelSetLatency; useLatency.modelGetLatencyAction += dSLatency.ReceiveModelGetLatency; useLoadLevel.modelGetLatencyAction += dSLatency.ReceiveModelGetLatency; useJukeTime.modelGetLatencyAction += dSLatency.ReceiveModelGetLatency; useCreateNote.noteAction += outCreateNote.ReceiveNote; outMap.noteAction += outCreateNote.ReceiveNote; inMenuEdit.menuStateAction += conMenuState.ReceiveMenuState; inMenuExitEdit.menuStateAction += conMenuState.ReceiveMenuState; inMenuLatency.menuStateAction += conMenuState.ReceiveMenuState; inMenuGame.menuStateAction += conMenuState.ReceiveMenuState; inMenuExitLatency.menuStateAction += conMenuState.ReceiveMenuState; inMenuExitGame.menuStateAction += conMenuState.ReceiveMenuState; conMenuExitGame.modelOutMenuAction += outMenu.ReceiveModelOutMenu; conMenuExitEdit.modelOutMenuAction += outMenu.ReceiveModelOutMenu; conMenuExitLatency.modelOutMenuAction += outMenu.ReceiveModelOutMenu; conMenuLatency.modelOutMenuAction += outMenu.ReceiveModelOutMenu; conMenuGame.modelOutMenuAction += outMenu.ReceiveModelOutMenu; conMenuEdit.modelOutMenuAction += outMenu.ReceiveModelOutMenu; conMenuExitLatency.modelOutLatencyAction += outLatency.ReceiveModelOutLatency; conMenuLatency.modelOutLatencyAction += outLatency.ReceiveModelOutLatency; conMenuGame.modelOutGameAction += outGame.ReceiveModelOutGame; conMenuExitGame.modelOutGameAction += outGame.ReceiveModelOutGame; conMenuExitEdit.modelOutEditAction += outEdit.ReceiveModelOutEdit; conMenuEdit.modelOutEditAction += outEdit.ReceiveModelOutEdit; inNet.modelInNetAction += outNet.ReceiveModelInNet; inNet.modelInNetAction += useNoteKiller.ReceiveModelInNet; useAbortLevel.modelOutClearAction += outClear.ReceiveModelOutClear; conMenuExitGame.modelOutClearAction += outClear.ReceiveModelOutClear; outSetSong.modelOutSetSongAction += outJukebox.ReceiveModelOutSetSong; conMenuState.menuStateAction += outCam.ReceiveMenuState; conMenuState.menuStateAction += inNet.ReceiveMenuState; conMenuState.menuStateAction += inWin.ReceiveMenuState; conMenuState.menuStateAction += outCardCtrl.ReceiveMenuState; outJukebox.timeInfAction += inJukeTime.ReceiveTimeInf; outJukebox.timeInfAction += inWin.ReceiveTimeInf; outJukebox.timeInfAction += inLatency.ReceiveTimeInf; useInitLevel.modelCrtInsLevelCardAction += facLevelCard.ReceiveModelCrtInsLevelCard; outInitSong.modelCrtInsSongCardAction += facSongCard.ReceiveModelCrtInsSongCard; outCardCtrl.modelGetInsSongCardAction += facSongCard.ReceiveModelGetInsSongCard; outCardCtrl.modelGetInsLevelCardAction += facLevelCard.ReceiveModelGetInsLevelCard; inJukeMove.modelInJukeMoveToOutJukeboxAction += outJukebox.ReceiveModelInJukeMoveToOutJukebox; inJukebox.jukeOpAction += outJukebox.ReceiveJukeOp; inJukeSpeed.modelInJukeSpeedToOutJukeboxAction += outJukebox.ReceiveModelInJukeSpeedToOutJukebox; useLoadLevel.loadLevelAssetAction += outMap.ReceiveLoadLevelAsset; useDeleteNote.modelUseDeleteNoteToOutDeleteNoteAction += outDeleteNote.ReceiveModelUseDeleteNoteToOutDeleteNote; conAbortLevel.modelConAbortLevelToUseAbortLevelAction += useAbortLevel.ReceiveModelConAbortLevelToUseAbortLevel; inSaveLevel.modelInSaveLevelToUseSaveLevelAction += useSaveLevel.ReceiveModelInSaveLevelToUseSaveLevel; conLoadLevel.modelConLoadLevelToUseLoadLevelAction += useLoadLevel.ReceiveModelConLoadLevelToUseLoadLevel; inDeleteNote.modelInDeleteNoteToUseDeleteNoteAction += useDeleteNote.ReceiveModelInDeleteNoteToUseDeleteNote; inCreateNote.noteAction += useCreateNote.ReceiveNote; inInit.modelInInitToUseInitSongAction += useInitSong.ReceiveModelInInitToUseInitSong; conSetSong.modelConSetSongToUseSetSongAction += useSetSong.ReceiveModelConSetSongToUseSetSong; useSetSong.modelUseSetSongToOutSetSongAction += outSetSong.ReceiveModelUseSetSongToOutSetSong; useInitSong.modelUseInitSongToOutInitSongAction += outInitSong.ReceiveModelUseInitSongToOutInitSong; inLatency.modelInLatencyToUseLatencyAction += useLatency.ReceiveModelInLatencyToUseLatency; inLatencyReset.modelInLatencyResetToUseLatencyResetAction += useLatencyReset.ReceiveModelInLatencyResetToUseLatencyReset; useLatency.modelUseLatencyToOutLatencyDisplayAction += outLatencyDisplay.ReceiveModelUseLatencyToOutLatencyDisplay; inMenuEdit.modelInMenuEditToConMenuEditAction += conMenuEdit.ReceiveModelInMenuEditToConMenuEdit; inMenuExitEdit.modelInMenuExitEditToConMenuExitEditAction += conMenuExitEdit.ReceiveModelInMenuExitEditToConMenuExitEdit; inMenuGame.modelInMenuGameToConMenuGameAction += conMenuGame.ReceiveModelInMenuGameToConMenuGame; conMenuGame.modelConMenuGameToConLoadLevelAction += conLoadLevel.ReceiveModelConMenuGameToConLoadLevel; inMenuLatency.modelInMenuLatencyToConMenuLatencyAction += conMenuLatency.ReceiveModelInMenuLatencyToConMenuLatency; inMenuExitGame.modelInMenuExitGameToConMenuExitGameAction += conMenuExitGame.ReceiveModelInMenuExitGameToConMenuExitGame; conMenuExitEdit.modelConMenuExitEditToConAbortLevelAction += conAbortLevel.ReceiveModelConMenuExitEditToConAbortLevel; inMenuExitLatency.modelInMenuExitLatencyToConMenuExitLatencyAction += conMenuExitLatency.ReceiveModelInMenuExitLatencyToConMenuExitLatency; inJukeTime.modelInJukeTimeToUseJukeTimeAction += useJukeTime.ReceiveModelInJukeTimeToUseJukeTime; useJukeTime.modelUseJukeTimeToOutJukeTimeAction += outJukeTime.ReceiveModelUseJukeTimeToOutJukeTime; useLoadLevel.modelUseLoadLevelToUseNoteKillerAction += useNoteKiller.ReceiveModelUseLoadLevelToUseNoteKiller; useNoteKiller.modelUseNoteKillerToUseHPAction += useHP.ReceiveModelUseNoteKillerToUseHP; useHP.modelUseHPToOutHPAction += outHP.ReceiveModelUseHPToOutHP; useHP.modelUseHPToOutFailAction += outFail.ReceiveModelUseHPToOutFail; inWin.modelInWinToOutWinAction += outWin.ReceiveModelInWinToOutWin; useLatencyReset.modelUseLatencyResetToOutLatencyDisplayAction += outLatencyDisplay.ReceiveModelUseLatencyResetToOutLatencyDisplay; inInit.modelInInitToUseInitLevelAction += useInitLevel.ReceiveModelInInitToUseInitLevel; conMenuEdit.modelConSetSongAction += conSetSong.ReceiveModelConSetSong; conLoadLevel.modelConSetSongAction += conSetSong.ReceiveModelConSetSong; }
public void DeleteNote(int id) { DBNote.DeleteNote(id); }
public void UpdateNote(Note m_Note) { DBNote.UpdateNote(m_Note); }
public List <Note> RetrieveAll(int typeRelatedId, string noteType) { List <Note> m_Notes = DBNote.RetrieveAll(typeRelatedId, noteType); return(m_Notes); }
public Note RetrieveNote(int id) { Note m_Note = DBNote.RetrieveNote(id); return(m_Note); }
public void AddNote(Note m_Note) { DBNote.AddNote(m_Note); }