· 7 years ago · Apr 23, 2018, 07:00 PM
1private byte[] Encrypt(byte[] data)
2{
3 byte[] secretKey = new byte[] { 1, 2, 3 };
4
5 IBuffer key = Convert.FromBase64String(Convert.ToBase64String(secretKey.ToArray()).ToString()).AsBuffer();
6 Debug.WriteLine(key.Length);
7 SymmetricKeyAlgorithmProvider algorithmProvider = SymmetricKeyAlgorithmProvider.OpenAlgorithm(SymmetricAlgorithmNames.AesCbc);
8 CryptographicKey cryptographicKey = algorithmProvider.CreateSymmetricKey(key);
9 IBuffer bufferEncrypt = CryptographicEngine.Encrypt(cryptographicKey, data.AsBuffer(), null);
10
11 return bufferEncrypt.ToArray();
12}
13
14+ this {Project.Auth} Project.Auth
15+ data {byte[15]} byte[]
16bufferEncrypt null Windows.Storage.Streams.IBuffer
17+ cryptographicKey {Windows.Security.Cryptography.Core.CryptographicKey} Windows.Security.Cryptography.Core.CryptographicKey
18+ key {System.Runtime.InteropServices.WindowsRuntime.WindowsRuntimeBuffer} Windows.Storage.Streams.IBuffer {System.Runtime.InteropServices.WindowsRuntime.WindowsRuntimeBuffer}
19+ algorithmProvider {Windows.Security.Cryptography.Core.SymmetricKeyAlgorithmProvider} Windows.Security.Cryptography.Core.SymmetricKeyAlgorithmProvider
20+ SecretKey Count = 16 System.Collections.Generic.List<byte>