-
-
Save polatengin/a6ebd8a3a695f7de71232ba4bbd197b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//ASP.NET MVC ile resim içerisine metin gömme (Steganography) | |
http://www.enginpolat.com/asp-net-mvc-ile-resim-icerisine-metin-gomme-steganography/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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
this is quite a nice code