3using System.Security.Cryptography;
4using System.Threading.Tasks;
8using System.Collections.Generic;
15 [CollectionName(
"QuickLoginAttachments")]
16 [Index(
"AttachmentId",
"Width",
"Height")]
50 public string ETag {
get;
set; }
65 public byte[]
Key {
get;
set; }
70 public byte[]
IV {
get;
set; }
76 internal async Task<byte[]> Load()
78 Aes Aes = Aes.Create();
82 Aes.Mode = CipherMode.CBC;
83 Aes.Padding = PaddingMode.PKCS7;
87 using (ICryptoTransform Decryptor = Aes.CreateDecryptor(this.
Key, this.
IV))
89 return Decryptor.TransformFinalBlock(Encrypted, 0, Encrypted.Length);
105 byte[] Decrypted = await this.Load();
117 internal async Task<KeyValuePair<byte[], string>> Scale(
int Width,
int Height)
119 if (!this.
ContentType.StartsWith(
"image/", StringComparison.OrdinalIgnoreCase))
122 byte[] Original = await this.Load();
127 double ScaleX = ((double)
Width) / Image.Width;
128 double ScaleY = ((double)
Height) / Image.Height;
129 double Scale = Math.Min(ScaleX, ScaleY);
130 int W = (int)(Image.Width * Scale + 0.5);
131 int H = (int)(Image.Height * Scale + 0.5);
133 using (SKSurface Surface = SKSurface.Create(
new SKImageInfo(W, H, SKImageInfo.PlatformColorType, SKAlphaType.Premul)))
135 SKCanvas Canvas = Surface.Canvas;
136 SKPaint Paint =
new SKPaint()
138 FilterQuality = SKFilterQuality.High,
142 Canvas.DrawImage(Image,
new SKRect(0, 0, W, H), Paint);
144 using (SKImage ScaledImage = Surface.Snapshot())
Static class managing encoding and decoding of internet content.
static Task< KeyValuePair< byte[], string > > EncodeAsync(object Object, Encoding Encoding, params string[] AcceptedContentTypes)
Encodes an object.
static Task< object > DecodeAsync(string ContentType, byte[] Data, Encoding Encoding, KeyValuePair< string, string >[] Fields, Uri BaseUri)
Decodes an object.
Static class managing loading of resources stored as embedded resources or in content files.
static async Task< byte[]> ReadAllBytesAsync(string FileName)
Reads a binary file asynchronously.
Represents an HTTP request.
HttpRequestHeader Header
Request header.
Represets a response of an HTTP client request.
void SetHeader(string FieldName, string Value)
Sets a custom header field value.
async Task Return(object Object)
Returns an object to the client. This method can only be called once per response,...
If the client has performed a conditional GET request and access is allowed, but the document has not...
Stores the contents of an attachment of a Quick-Login identity.
byte[] IV
AES-256 IV to use to decrypt file.
string FileName
File name of encrypted attachment.
QuickLoginAttachment()
Stores the contents of an attachment of a Quick-Login identity.
int? Height
Optional height restriction
string ETag
ETag value of content.
string AttachmentId
Attachment ID
byte[] Key
AES-256 key to use to decrypt file.
int? Width
Optional width restriction
string ContentType
Content-Type of attachment.