Пример #1
0
        public string Decrypt(string key, string encData)
        {
            using (Aes myAes = Aes.Create())
            {
                myAes.Key     = dataToSHA256(key);
                myAes.Mode    = CipherMode.CBC;
                myAes.Padding = PaddingMode.PKCS7;

                return(AESHelper.DecryptAES(encData, myAes.Key));
            }
        }
        private byte[] GetByteFile(IFormFile fileData, bool isGetFromBlob, string containerName, string blobName)
        {
            var decryptKey = AzureKeyVaultProvider.AESKeyBLOB;

            // tại sao bên đây có case này còn bên payment thì default là down luon?
            if (isGetFromBlob)
            {
                //Non Vault
                var storageConnectionString = AzureKeyVaultProvider.StorageConnectionString;
                return(BlobHelper.DownloadFileToArrayByte(storageConnectionString, containerName, blobName, decryptKey));
            }
            // register to read content of excel file
            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

            byte[] fileContent = null;
            using (var ms = new MemoryStream())
            {
                fileData.CopyTo(ms);
                fileContent = ms.ToArray();
            }
            return(AESHelper.DecryptAES(fileContent, decryptKey));
        }
Пример #3
0
 private void InitilizeCoreVault()
 {
     AESSecretKey                    = _configuration["AESSecretKey"];
     IOConnectorAESKeyBLOB           = _configuration["IOConnectorAESKeyBLOB"];
     DBConnectionServerName          = _configuration["DBConnectionServerName"];
     DBConnectionUserName            = _configuration["DBConnectionUserName"];
     DBConnectionPassword            = _configuration["DBConnectionPassword"];
     DBConnectionDBName              = _configuration["DBConnectionDBName"];
     StorageAccountNameShared        = _configuration["StorageAccountNameShared"];
     SharedApiVCardWebForWexEndpoint = _configuration["SharedApiVCardWebForWexEndpoint"];
     SharedApiVCardWebForWexKey      = _configuration["SharedApiVCardWebForWexKey"];
     StorageAccountKeyShared         = _configuration["StorageAccountKeyShared"];
     StorageSharedConnectionString   = $"DefaultEndpointsProtocol=https;AccountName={StorageAccountNameShared};AccountKey={AESHelper.DecryptAES(StorageAccountKeyShared, AESSecretKey)}";
 }