tesses-backup/TessesDedup/AccessKey.cs

34 lines
842 B
C#
Raw Permalink Normal View History

2024-07-23 03:49:40 +00:00
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);
}
}
}