12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- using System;
- using System.IO;
- using System.Security.Cryptography;
- using System.Text;
- namespace Showlicense
- {
- internal static class AesHelper
- {
- /// <summary>
- /// "Vinno.vCloud.CurrentLicense" two MD5
- /// </summary>
- private const string Key = "2A4A2B05EFD02D5BDEBB55711213BBBD";
- /// <summary>
- /// Gets Decrypt text
- /// </summary>
- /// <param name="inputText"></param>
- /// <returns></returns>
- internal static string Decrypt(string inputText)
- {
- return AesDecrypt(inputText, Key);
- }
- /// <summary>
- /// AES algorithm Decrypt string
- /// </summary>
- /// <param name="cipherText"></param>
- /// <param name="keyString">AES Key</param>
- /// <returns></returns>
- private static string AesDecrypt(string cipherText, string keyString)
- {
- var fullCipher = Convert.FromBase64String(cipherText);
- byte[] iv = new byte[16];
- var cipher = new byte[fullCipher.Length - iv.Length];
- Buffer.BlockCopy(fullCipher, 0, iv, 0, iv.Length);
- Buffer.BlockCopy(fullCipher, iv.Length, cipher, 0, fullCipher.Length - iv.Length);
- var key = Encoding.UTF8.GetBytes(keyString);
- using (var aesAlg = Aes.Create())
- {
- using (var decryptor = aesAlg.CreateDecryptor(key, iv))
- {
- string result;
- using (var msDecrypt = new MemoryStream(cipher))
- {
- using (var csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
- {
- using (var srDecrypt = new StreamReader(csDecrypt))
- {
- result = srDecrypt.ReadToEnd();
- }
- }
- }
- return result;
- }
- }
- }
- }
- }
|