亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? cryptutility.cs

?? Hiding Text in a Image
?? CS
字號:
/*
 * This class has been written by
 * Corinna John (Hannover, Germany)
 * picturekey@binary-universe.net
 * 
 * You can use the code in any context you like,
 * as long as you do not delete this comment.
 * */

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Text;
using System.IO;

namespace PictureKey {

	public class CryptUtility {

		/// <summary>Hides a message in a bitmap</summary>
		/// <param name="messageStream">The message to hide</param>
		/// <param name="bitmap">The carrier bitmap</param>
		/// <param name="keyStream">The key to use</param>
		public static void HideMessageInBitmap(Stream messageStream, Bitmap bitmap, Stream keyStream, bool useGrayscale){
			HideOrExtract(ref messageStream, bitmap, keyStream, false, useGrayscale);
			messageStream = null;
		}

		/// <summary>Extracts an hidden message from a bitmap</summary>
		/// <param name="bitmap">The carrier bitmap</param>
		/// <param name="keyStream">The key used for hiding the message</param>
		/// <param name="messageStream">Empty stream to receive the message</param>
		public static void ExtractMessageFromBitmap(Bitmap bitmap, Stream keyStream, ref Stream messageStream){
			HideOrExtract(ref messageStream, bitmap, keyStream, true, false);
		}

		/// <summary>Stepts through the pixels of a bitmap using a key pattern and hides or extracts a message</summary>
		/// <param name="messageStream">If exctract is false, the message to hide - otherwise an empty stream to receive the extracted message</param>
		/// <param name="bitmap">The carrier bitmap</param>
		/// <param name="keyStream">The key specifying the unchanged pixels between two hidden bytes</param>
		/// <param name="extract">Extract a hidden message (true), or hide a message in a clean carrier bitmap (false)</param>
		private static void HideOrExtract(ref Stream messageStream, Bitmap bitmap, Stream keyStream, bool extract, bool useGrayscale){
			//Current count of pixels between two hidden message-bytes
			//Changes with every hidden byte according to the key
			int currentStepWidth = 0;
			//Current byte in the key stream - normal direction
			byte currentKeyByte;
			//Current byte in the key stream - reverse direction
			byte currentReverseKeyByte;
			//current position in the key stream
			long keyPosition;

			//maximum X and Y position
			int bitmapWidth = bitmap.Width-1;
			int bitmapHeight = bitmap.Height-1;
			
			//Color component to hide the next byte in (0-R, 1-G, 2-B)
			//Rotates with every hidden byte
			int currentColorComponent = 0;
			
			//Stores the color of a pixel
			Color pixelColor;
			
			//Length of the message
			Int32 messageLength;

			if(extract){
				//Read the length of the hidden message from the first pixel
				pixelColor = bitmap.GetPixel(0,0);
				messageLength = (pixelColor.R << 2) + (pixelColor.G << 1) + pixelColor.B;
				messageStream = new MemoryStream(messageLength);
			}else{
				
				messageLength = (Int32)messageStream.Length;

				if(messageStream.Length >= 16777215){ //The message is too long
					String exceptionMessage = "Themessage is too long, only 16777215 bytes are allowed.";
					throw new Exception(exceptionMessage);
				}
				
				//Check size of the carrier image
				
				//Pixels available
				long countPixels = (bitmapWidth*bitmapHeight) -1;
				//Pixels required - start with one pixel for length of message
				long countRequiredPixels = 1;
				//add up the gaps between used pixels (sum up all the bytes of the key)
				while((keyStream.Position < keyStream.Length)&&(keyStream.Position < messageLength)){
					countRequiredPixels += keyStream.ReadByte();
				}
				//If the key is shorter than the message, it will be repeated again and again
				//Multiply with count of key periods
				countRequiredPixels *= (long)System.Math.Ceiling( ((float)messageStream.Length / (float)keyStream.Length) );

				if(countRequiredPixels > countPixels){ //The bitmap is too small
					String exceptionMessage = "The image is too small for this message and key. "+countRequiredPixels+" pixels are required.";
					throw new Exception(exceptionMessage);
				}
				
				//Write length of the bitmap into the first pixel
				int colorValue = messageLength;
				int red = colorValue >> 2;
				colorValue -= red << 2;
				int green = colorValue >> 1;
				int blue = colorValue - (green << 1);
				pixelColor = Color.FromArgb(red, green, blue);
				bitmap.SetPixel(0,0, pixelColor);
			}
			
			//Reset the streams
			keyStream.Seek(0, SeekOrigin.Begin);
			messageStream.Seek(0, SeekOrigin.Begin);

			//Current position in the carrier bitmap
			//Start with 1, because (0,0) contains the message's length
			Point pixelPosition = new Point(1,0);

			//Loop over the message and hide each byte
			for(int messageIndex=0; messageIndex<messageLength; messageIndex++){
				
				//repeat the key, if it is shorter than the message
				if(keyStream.Position == keyStream.Length){
					keyStream.Seek(0, SeekOrigin.Begin);
				}
				//Get the next pixel-count from the key, use "1" if it's 0
				currentKeyByte = (byte)keyStream.ReadByte();
				currentStepWidth = (currentKeyByte==0) ? (byte)1 : currentKeyByte;

				//jump to reverse-read position and read from the end of the stream
				keyPosition = keyStream.Position;
				keyStream.Seek(-keyPosition, SeekOrigin.End);
				currentReverseKeyByte = (byte)keyStream.ReadByte();
				//jump back to normal read position
				keyStream.Seek(keyPosition, SeekOrigin.Begin);
				
				//Perform line breaks, if current step is wider than the image
				while(currentStepWidth > bitmapWidth){
					currentStepWidth -= bitmapWidth;
					pixelPosition.Y++;
				}
				
				//Move X-position
				if((bitmapWidth - pixelPosition.X) < currentStepWidth){
					pixelPosition.X = currentStepWidth - (bitmapWidth - pixelPosition.X);	
					pixelPosition.Y++;
				}else{
					pixelPosition.X += currentStepWidth;
				}

				//Get color of the "clean" pixel
				pixelColor = bitmap.GetPixel(pixelPosition.X, pixelPosition.Y);

				if(extract){
					//Extract the hidden message-byte from the color
					byte foundByte = (byte)(currentReverseKeyByte ^ GetColorComponent(pixelColor, currentColorComponent));
					messageStream.WriteByte(foundByte);
					//Rotate color components
					currentColorComponent = (currentColorComponent==2) ? 0 : (currentColorComponent+1);

				}else{
					//To add a bit of confusion, xor the byte with a byte read from the keyStream
					int currentByte = messageStream.ReadByte() ^ currentReverseKeyByte;
					
					if(useGrayscale){
						pixelColor = Color.FromArgb(currentByte, currentByte, currentByte);
					}else{
						//Change one component of the color to the message-byte
						SetColorComponent(ref pixelColor, currentColorComponent, currentByte);
						//Rotate color components
						currentColorComponent = (currentColorComponent==2) ? 0 : (currentColorComponent+1);
					}
					bitmap.SetPixel(pixelPosition.X, pixelPosition.Y, pixelColor);
				}
			}

			//the stream will be closed by the calling method
			bitmap = null;
			keyStream = null;
		}

		/// <summary>Return one component of a color</summary>
		/// <param name="pixelColor">The Color</param>
		/// <param name="colorComponent">The component to return (0-R, 1-G, 2-B)</param>
		/// <returns>The requested component</returns>
		private static byte GetColorComponent(Color pixelColor, int colorComponent){
			byte returnValue = 0;
			switch(colorComponent){
				case 0:
					returnValue = pixelColor.R;
					break;
				case 1:
					returnValue = pixelColor.G;
					break;
				case 2:
					returnValue = pixelColor.B;
					break;
			}
			return returnValue;
		}

		/// <summary>Changees one component of a color</summary>
		/// <param name="pixelColor">The Color</param>
		/// <param name="colorComponent">The component to change (0-R, 1-G, 2-B)</param>
		/// <param name="newValue">New value of the component</param>
		private static void SetColorComponent(ref Color pixelColor, int colorComponent, int newValue){
			switch(colorComponent){
				case 0:
					pixelColor = Color.FromArgb(newValue, pixelColor.G, pixelColor.B);
					break;
				case 1:
					pixelColor = Color.FromArgb(pixelColor.R, newValue, pixelColor.B);
					break;
				case 2:
					pixelColor = Color.FromArgb(pixelColor.R, pixelColor.G, newValue);
					break;
			}
		}

		private static String UnTrimColorString(String color, int desiredLength){
			int difference = desiredLength - color.Length;
			if(difference > 0){
				color = new String('0', difference) + color;
			}
			return color;
		}

	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品成人免费| 91原创在线视频| 欧美一级午夜免费电影| 热久久一区二区| 91精品国产欧美一区二区18| 日本视频在线一区| 欧美精品一区二区三区蜜桃| 国产成人免费视频网站| 综合在线观看色| 在线亚洲+欧美+日本专区| 亚洲成人你懂的| 欧美一区二区日韩一区二区| 国模无码大尺度一区二区三区| 欧美激情在线看| 91蝌蚪porny成人天涯| 午夜天堂影视香蕉久久| 欧美tickling网站挠脚心| 国产成人精品影院| 伊人色综合久久天天人手人婷| 欧美日韩一区二区在线观看 | 国产精品视频免费看| 成人激情开心网| 午夜伊人狠狠久久| 久久综合狠狠综合| 日本黄色一区二区| 久久精品国产77777蜜臀| 国产精品进线69影院| 91精品免费观看| 99这里只有精品| 日本aⅴ精品一区二区三区| 欧美国产一区二区| 日韩一区二区三区四区五区六区| 国产福利精品一区| 亚洲国产日韩综合久久精品| 337p日本欧洲亚洲大胆精品| av激情综合网| 黄色小说综合网站| 亚洲一区二区三区四区不卡| 亚洲精品在线电影| 欧美日韩精品一区视频| 成人午夜在线免费| 久久99精品视频| 亚洲乱码一区二区三区在线观看| 精品动漫一区二区三区在线观看| 欧美日韩午夜在线| 成人av免费观看| 国产一区二区三区电影在线观看| 一区二区三区中文字幕在线观看| 久久久精品影视| 欧美精品粉嫩高潮一区二区| 91美女在线观看| 国产又黄又大久久| 青青草原综合久久大伊人精品| 一区二区三区不卡在线观看| 国产欧美日韩在线| 精品国产免费一区二区三区香蕉| 欧美日韩中文字幕一区| 99热这里都是精品| 国产成人精品亚洲777人妖 | 91成人免费在线| 成人av综合在线| 国产资源在线一区| 久久99精品国产麻豆婷婷| 亚洲综合一区二区精品导航| 中文字幕色av一区二区三区| 国产视频一区二区在线| 日韩欧美中文字幕公布| 884aa四虎影成人精品一区| 欧美色网一区二区| 欧美视频一区二区三区四区| 色欧美日韩亚洲| 色网综合在线观看| 91麻豆产精品久久久久久 | 亚洲精品中文在线| 亚洲视频一区二区免费在线观看| 国产精品久久久99| 国产精品国产精品国产专区不蜜| 欧美经典一区二区| 中文一区二区在线观看| 国产色91在线| 国产精品电影一区二区| 国产精品毛片久久久久久| 中文字幕中文乱码欧美一区二区| 日本一区二区电影| 亚洲激情综合网| 亚洲五码中文字幕| 蜜臀va亚洲va欧美va天堂| 美国三级日本三级久久99| 国产在线一区二区| 风间由美中文字幕在线看视频国产欧美| 国产激情视频一区二区在线观看| 国产不卡免费视频| 91麻豆文化传媒在线观看| 在线一区二区三区四区五区 | av男人天堂一区| 日本道精品一区二区三区| 欧美日韩一区二区三区在线| 欧美高清视频不卡网| 欧美成人a∨高清免费观看| 久久久天堂av| 亚洲蜜桃精久久久久久久| 亚洲午夜久久久久| 久久精品av麻豆的观看方式| 国产suv精品一区二区883| 91在线视频网址| 91精品国产综合久久香蕉麻豆| 欧美va在线播放| 亚洲欧洲成人av每日更新| 亚洲成年人影院| 激情五月激情综合网| 成人爱爱电影网址| 欧美高清视频在线高清观看mv色露露十八 | 日韩av一区二区在线影视| 国产在线精品一区二区夜色| 91香蕉视频在线| 91精品视频网| 国产精品国产三级国产普通话三级| 午夜精品久久久久久| 国产精品一卡二| 欧美视频你懂的| 国产欧美精品一区| 日韩精品亚洲专区| 不卡av在线网| 日韩免费视频一区| 亚洲精品国产成人久久av盗摄| 精品一区二区三区久久久| 91麻豆国产在线观看| 日韩一级片网站| 亚洲高清三级视频| 成人黄色一级视频| 欧美成人精品高清在线播放| 亚洲精品视频在线看| 国产黄色精品视频| 91.com视频| 亚洲品质自拍视频| 国产91丝袜在线观看| 91精品国产色综合久久| 一区二区三区在线免费视频| 国产成人在线观看免费网站| 91麻豆精品国产91久久久| 亚洲精品成人在线| av网站一区二区三区| 精品国产伦理网| 三级欧美韩日大片在线看| 欧洲生活片亚洲生活在线观看| 久久久www成人免费无遮挡大片 | 日韩欧美三级在线| 一区二区三区.www| 99久久婷婷国产综合精品| 久久久不卡网国产精品一区| 美女视频网站黄色亚洲| 欧美福利一区二区| 亚洲一区二区黄色| 色菇凉天天综合网| 日韩美女精品在线| 成人精品一区二区三区四区 | 欧美日韩色综合| 亚洲欧洲中文日韩久久av乱码| 成人免费av网站| 国产亚洲视频系列| 国产精品亚洲一区二区三区在线| 日韩一级片在线观看| 日本在线不卡视频| 欧美麻豆精品久久久久久| 亚洲成av人影院在线观看网| 在线视频一区二区免费| 一区二区在线观看不卡| 91浏览器入口在线观看| 亚洲同性同志一二三专区| 成人国产视频在线观看| **网站欧美大片在线观看| 国产suv一区二区三区88区| 国产精品美女久久久久高潮| 99国产精品久久久久久久久久久| 中文字幕一区在线| 色噜噜久久综合| 亚洲永久精品国产| 欧美精品久久久久久久多人混战| 日本一不卡视频| 精品卡一卡二卡三卡四在线| 精品写真视频在线观看| 国产视频在线观看一区二区三区| 成人在线视频首页| 亚洲精品欧美专区| 在线成人午夜影院| 国产在线一区观看| 18成人在线观看| 欧美三级欧美一级| 国内精品国产成人国产三级粉色 | 精品一区二区三区久久久| 国产欧美视频一区二区| 91亚洲午夜精品久久久久久| 亚洲电影你懂得| 欧美一级国产精品| 成人精品电影在线观看| 一区二区三区在线观看视频 | 欧美日韩国产电影| 精品一区二区三区在线观看国产 | 国产精品久久久久影院| 色综合久久中文综合久久97|