Create a gist now

Instantly share code, notes, and snippets.

@polatengin /982
Last active Oct 3, 2016

//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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment