// Private Methods (2) private void TaskAction_Decrypt() { DecryptionHelper.CreateDecryptionTask(this.CONTEXT, this.SOURCE, this.DESTINATION, this.XML) .RunSynchronously(); }
private static void StartDecryption(CryptExecutionContext ctx) { var tasks = new List <Task>(); tasks.Add(DecryptionHelper.CreateDecryptionTask(ctx)); // ... and start them foreach (var t in tasks) { t.Start(); } TaskHelper.WaitAll(tasks); }
/// <summary> /// Decrypts an text hidden inside the image. /// </summary> /// <param name="image">The bytes of the image where the message is hidden.</param> /// <param name="skipAlpha">Should the alpha channel remain untouched?.</param> /// <returns>An array of bytes with the text that was hidden.</returns> private static byte[] DecryptStringMessage(byte[] image, bool skipAlpha) { //Transfome bytes to bits. BitArray imageBits = new BitArray(image); //Get the size of the message we'll have to decrypt, at the beginning of the image. int messageSize = DecryptionHelper.GetMessageSize(imageBits, 0, skipAlpha); //Empty array of bits the size of the message size we just got. BitArray messageBits = new BitArray(messageSize); //Decrypts the message. byte[] messageDecrypted = DecryptionHelper.GetDecryptedMessage(imageBits, messageBits, SizeInfo.Text, skipAlpha); return(messageDecrypted); }
/// <summary> /// Decrypts an image hidden inside the image. /// </summary> /// <param name="image">The bytes of the image where the message is hidden.</param> /// <param name="skipAlpha">Should the alpha channel remain untouched?.</param> /// <returns>An array of bytes with the image that was hidden.</returns> private static byte[] DecryptImageMessage(byte[] image, bool skipAlpha) { //Transform bytes to bits. BitArray imageBits = new BitArray(image); //Get the size of the message we'll have to decrypt, at the beginning of the image. Steganography.embeddedWidth = DecryptionHelper.GetMessageSize(imageBits, 0, skipAlpha); Steganography.embeddedHeight = DecryptionHelper.GetMessageSize(imageBits, 24 * 8, skipAlpha); //Empty array of bits the size of the message size we just got. BitArray messageBits = new BitArray(Steganography.embeddedWidth * Steganography.embeddedHeight * 32); //Decrypts the message. byte[] messageDecrypted = DecryptionHelper.GetDecryptedMessage(imageBits, messageBits, SizeInfo.Image, skipAlpha); return(messageDecrypted); }
static ExternalServiceBase() { string cesEncryptedPwd = ConfigurationManager.AppSettings.Get("CESServiceAccountPassword"); if (!string.IsNullOrEmpty(cesEncryptedPwd)) { CESPassword = DecryptionHelper.DecryptString(cesEncryptedPwd); } string svcEncryptedPwd = ConfigurationManager.AppSettings.Get("ServiceAccountPassword"); if (!string.IsNullOrEmpty(svcEncryptedPwd)) { SvcPassword = DecryptionHelper.DecryptString(svcEncryptedPwd); } System.Net.ServicePointManager.ServerCertificateValidationCallback += (se, cert, chain, sslerror) => { return(true); }; }
// Private Methods (2) private void TaskAction_Decrypt() { var pwd = Convert.FromBase64String(this.XML.Attribute("pwd").Value.Trim()); using (var srcStream = this.SOURCE.OpenRead()) { using (var destStream = new FileStream(this.DESTINATION.FullName, FileMode.CreateNew, FileAccess.ReadWrite)) { DecryptionHelper.DecryptStream(srcStream, destStream, pwd, this.SALT); } } FileSystemHelper.TrySetCreationTimeUtc(this.DESTINATION, new DateTimeOffset(ticks: long.Parse(this.XML.Attribute("created").Value.Trim()), offset: TimeSpan.Zero)); FileSystemHelper.TrySetLastWriteTimeUtc(this.DESTINATION, new DateTimeOffset(ticks: long.Parse(this.XML.Attribute("lastWrite").Value.Trim()), offset: TimeSpan.Zero)); }
public async Task <ActionResult <string> > Post([FromQuery] string validationToken = null) { // handle validation if (!string.IsNullOrEmpty(validationToken)) { _logger.LogInformation($"Received Token: '{validationToken}'"); return(Ok(validationToken)); } // handle notifications using (StreamReader reader = new StreamReader(Request.Body)) { string content = await reader.ReadToEndAsync(); Console.WriteLine(content); var notifications = JsonConvert.DeserializeObject <Model.NotificationModels.Notifications>(content); // var filePath = Path.Combine(_rootPath, _config["CertFilePath"]); // var certData = System.IO.File.ReadAllBytes(filePath); foreach (var notifi in notifications.Items) { // Initialize with the private key that matches the encryptionCertificateId. var data = DecryptionHelper.GetDecryptedContent(notifi.EncryptedContent, _config["WEBSITE_LOAD_CERTIFICATES"]); _logger.LogWarning("Received message: " + data); var message = JsonConvert.DeserializeObject <ChatMessage>(data); if (!_processedMessage.TryAdd(message.WebUrl, true)) { _logger.LogWarning("Multiple request received: " + message.WebUrl); _logger.LogWarning("_processedMessage.Count: " + _processedMessage.Count); continue; } var question = _messageParser.Parse(message); if (question.Forum == null) // Don't process if Forum is not populated. { _logger.LogWarning("Skipped message: " + data); continue; } } } return(Ok()); }
public dynamic GetDesDecrypt(string Text) { dynamic result = DecryptionHelper.DesDecrypt(Text); return(result); }