using System; using System.Collections.Generic; using System.Security.Cryptography; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Serialization; namespace TessesDedup { public class AccessKey { [JsonProperty("id")] public long Id {get;set;} [JsonIgnore] public string Key {get;set;}=""; [JsonIgnore] public long UserId {get;set;} [JsonProperty("device_name")] public string DeviceName {get;set;}=""; [JsonProperty("creation_date")] public DateTime CreationDate {get;set;} public void NewKey() { byte[] bytes=new byte[32]; using(var rnd = RandomNumberGenerator.Create()) rnd.GetBytes(bytes); Key = Convert.ToBase64String(bytes); } } }