public void SetNoteTextTest() { // Arrange byte[] derivedKey = new byte[16] { 111, 222, 31, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 104, 15, 16 }; SymmetricKeyAlgorithm ska = SymmetricKeyAlgorithm.GenerateNew(SymmetricEncryptionAlgorithm.AES_CTR); string title = "Top three"; string text = "Another long and super boring text for testing purposes."; Note note = new Note(title, text); NoteSecret noteSecret = new NoteSecret(note, "does not matter", ska, derivedKey); string noteText1 = "Not so boring but still bit something text for test case"; // Act bool shouldBeTrue = noteSecret.SetNoteText(noteText1, derivedKey); string noteText2 = noteSecret.GetNoteText(derivedKey); bool shouldBeFalse = noteSecret.SetNoteText(noteText1, new byte[] { 1, 2, 3 }); // Assert Assert.IsTrue(shouldBeTrue); Assert.IsFalse(shouldBeFalse); Assert.IsFalse(string.IsNullOrEmpty(noteText2)); Assert.AreEqual(noteText1, noteText2); }
public void GetNoteTextTest() { // Arrange byte[] derivedKey = new byte[16] { 15, 200, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 104, 15, 16 }; byte[] initialCounter = new byte[] { 0xf0, 0xf1, 0xfb, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xf3, 0xff }; SettingsAES_CTR settingsAES_CTR = new SettingsAES_CTR(initialCounter); SymmetricKeyAlgorithm skaAES_CTR = new SymmetricKeyAlgorithm(SymmetricEncryptionAlgorithm.AES_CTR, 128, settingsAES_CTR); string title = "Wishlist for holidays"; string text = "peace, happiness, freedom"; Note note = new Note(title, text); NoteSecret noteSecret = new NoteSecret(note, "does not matter", skaAES_CTR, derivedKey); // Act string noteText = noteSecret.GetNoteText(derivedKey); // Assert Assert.AreEqual(text, noteText); }
public static NoteSimplified TurnIntoEditable(NoteSecret noteSecret, byte[] derivedPassword, int zeroBasedIndexNumber) { return(new NoteSimplified() { zeroBasedIndexNumber = zeroBasedIndexNumber, IsSecure = true, Title = noteSecret.GetNoteTitle(derivedPassword), Text = noteSecret.GetNoteText(derivedPassword), CreationTime = noteSecret.GetCreationTime(derivedPassword).ToString("s", System.Globalization.CultureInfo.InvariantCulture), ModificationTime = noteSecret.GetModificationTime(derivedPassword).ToString("s", System.Globalization.CultureInfo.InvariantCulture), }); }