-
Notifications
You must be signed in to change notification settings - Fork 0
/
AzureJobProgress.cs
32 lines (30 loc) · 1.09 KB
/
AzureJobProgress.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System.Security.Cryptography;
class AzureJobProgress
{
public string Label { get; set; }
public string JobId { get; set; }
public string IV { get; set; }
public string Content { get; set; }
public string Decrypt(byte[] key)
{
using (Aes aes = Aes.Create())
{
aes.Key = key;
aes.IV = Convert.FromBase64String(IV);
aes.Mode = CipherMode.CBC;
using (ICryptoTransform decipher = aes.CreateDecryptor(aes.Key, aes.IV))
{
using (MemoryStream ms = new MemoryStream(Convert.FromBase64String(Content)))
{
using (CryptoStream cs = new CryptoStream(ms, decipher, CryptoStreamMode.Read))
{
using (StreamReader sr = new StreamReader(cs))
{
return sr.ReadToEnd();
}
}
}
}
}
}
}