请帮我隐身术 [英] Please help me in steganography

查看:87
本文介绍了请帮我隐身术的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为隐写术编写的代码加密已经完成,但是当我尝试解密时,它会给我一个解密值的空信息请帮助



< b>我尝试了什么:



whatever code I have write for Steganography with that code Encryption has done but when I try for Decryption then it gives me empty message of decrypted value please help

What I have tried:

public void encryption()
{
      var originalbmp = new Bitmap(Bitmap.FromFile("../../OriginalImage.png")); //Actual image used to encrypt the message
           
      var encryptbmp = new Bitmap(originalbmp.Width, originalbmp.Height); // To hold the encrypted image  

var originalText="My message to encrypr"; 
var ascii = new List<int>(); // To store individual value of the pixels 
      foreach (char character in originalText)
      {
             int asciiValue = Convert.ToInt16(character); // Convert the character to ASCII
             var firstDigit = asciiValue / 1000; // Extract the first digit of the ASCII
             var secondDigit = (asciiValue - (firstDigit * 1000)) / 100; //Extract the second digit of the ASCII
             var thirdDigit = (asciiValue - ((firstDigit * 1000) + (secondDigit * 100)))/10;//Extract the third digit of the ASCII
             var fourthDigit = (asciiValue - ((firstDigit * 1000) + (secondDigit * 100)+(thirdDigit * 10))); //Extract the third digit of the ASCII
             ascii.Add(firstDigit); // Add the first digit of the ASCII
             ascii.Add(secondDigit); // Add the second digit of the ASCII
             ascii.Add(thirdDigit); // Add the third digit of the ASCII
             ascii.Add(fourthDigit ); // Add the fourth digit of the ASCII
     }
     var count = 0; // Have a count
     for (int row = 0; row < originalbmp.Width; row++) // Indicates row number
     {
           for (int column = 0; column < originalbmp.Height; column++) // Indicate column number
           {
                 var color = originalbmp.GetPixel(row, column); // Get the pixel from each and every row and column
                 encryptbmp.SetPixel(row, column, Color.FromArgb(color.A -((count < ascii .Count ) ? ascii[count]:0), color)); // Set ascii value in A of the pixel
           }
    }
    encryptbmp.Save("../../EncryptedImage.png", ImageFormat.Png); // Save the encrypted image   
}

--------------------------------------------------------------------------------


private void decryption()
{
     var characterValue = 0; // Have a variable to store the ASCII value of the character
     string encryptedText = string.Empty; // Have a variable to store the encrypted text
     var ascii = new List<int>(); // Have a collection to store the collection of ASCII
     var encryptbmp = new Bitmap(Bitmap.FromFile("../../EncryptedImage.png")); // Load the transparent image
 
     for (int row = 0; row < encryptbmp.Width; row++) // Indicates row number
     {
           for (int column = 0; column < encryptbmp.Height; column++) // Indicate column number
           {
                var color = encryptbmp.GetPixel(row, column); // Get the pixel from each and every row and column
                 ascii.Add(255 - color.A); // Get the ascii value from A value since 255 is default value
           }
    }
    for (int i = 0; i < ascii.Count; i++)
    {
          characterValue = 0;
          characterValue += ascii[i] * 1000; // Get the first digit of the ASCII value of the encrypted character
          i++;
          characterValue += ascii[i] * 100; // Get the second digit of the ASCII value of the encrypted character
          i++;
          characterValue += ascii[i] * 10;  // Get the first third digit of the ASCII value of the encrypted character
          i++;
          characterValue += ascii[i]; // Get the first fourth digit of the ASCII value of the encrypted character
          if (characterValue != 0)
             encryptedText += char.ConvertFromUtf32(characterValue); // Convert the ASCII characterValue into character
          }
          MessageBox.Show(encryptedText); // Showing the encrypted message in message box
}

< br $> b $ b

参考:

http://www.c-sharpcorner.com/UploadFile/6f0898/simple-steganography-encryption-and-decryption-huge-message/

推荐答案

关于隐写术的整篇文章系列,使用 C#,代码项目:http://www.codeproject.com/Articles/Corinna-John#Article [ ^ ]。
There is a whole article series on steganography, using C#, here at Code Project: http://www.codeproject.com/Articles/Corinna-John#Article[^].


你应该学会使用调试器尽快。而不是猜测你的代码在做什么,现在是时候看到你的代码执行并确保它完成你期望的。



调试器允许你跟踪执行逐行检查变量,你会看到它有一个停止做你期望的点。

调试器 - 维基百科,免费的百科全书 [ ^ ]

掌握Visual Studio 2010中的调试 - A初学者指南 [ ^ ]



使用调试器,您将完全符合您的代码。
You should learn to use the debugger as soon as possible. Rather than guessing what your code is doing, It is time to see your code executing and ensuring that it does what you expect.

The debugger allow you to follow the execution line by line, inspect variables and you will see that there is a point where it stop doing what you expect.
Debugger - Wikipedia, the free encyclopedia[^]
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]

With the debugger, you will exactly what your code is doing.


这篇关于请帮我隐身术的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆