Skip to content

Instantly share code, notes, and snippets.

@polatengin
Last active May 27, 2017 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save polatengin/a6ebd8a3a695f7de71232ba4bbd197b0 to your computer and use it in GitHub Desktop.
Save polatengin/a6ebd8a3a695f7de71232ba4bbd197b0 to your computer and use it in GitHub Desktop.
//ASP.NET MVC ile resim içerisine metin gömme (Steganography)
http://www.enginpolat.com/asp-net-mvc-ile-resim-icerisine-metin-gomme-steganography/
[HttpPost]
public ActionResult Index(HttpPostedFileBase resim)
{
var original = new Bitmap(resim.InputStream);
var encrypted = new Bitmap(original.Width, original.Height);
var text = "Hello World!";
for (int iLoop = 0; iLoop < original.Width; iLoop++)
{
for (int yLoop = 0; yLoop < original.Height; yLoop++)
{
var pixel = original.GetPixel(iLoop, yLoop);
if (iLoop == 0 && yLoop < text.Length)
{
var letter = text[yLoop];
pixel = Color.FromArgb(pixel.R, pixel.G, letter);
}
encrypted.SetPixel(iLoop, yLoop, pixel);
}
}
using (var ms = new MemoryStream())
{
encrypted.Save(ms, ImageFormat.Jpeg);
return File(ms.ToArray(), "image/jpg");
}
}
<form method="post" enctype="multipart/form-data">
<input type="file" name="resim" />
<input type="submit" value="Gönder" />
</form>
@hardeydotun007
Copy link

this is quite a nice code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment