Rainy.Db.DbEncryptedStorage.GetEncryptedNoteKey C# (CSharp) Method

GetEncryptedNoteKey() private method

private GetEncryptedNoteKey ( DBNote note ) : string
note DBNote
return string
        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;
        }