private List <CryptoInfo> SetCryptoInfo(Dictionary <string, Crypto> res) { var cryptoInfos = new List <CryptoInfo>(); cryptoInfos.Clear(); foreach (var resKey in res.Keys) { var crypto = res[resKey]; var cryptoInfo = new CryptoInfo(); cryptoInfo.id = crypto.id; cryptoInfo.key = resKey; cryptoInfo.name = CryptoName.GetCryptoName(resKey); cryptoInfo.imgUrl = CryptoImage.GetCryptoImageUrl(resKey); cryptoInfo.last = crypto.last; cryptoInfo.lowestAsk = crypto.lowestAsk; cryptoInfo.highestBid = crypto.highestBid; cryptoInfo.percentChange = crypto.percentChange; cryptoInfo.baseVolume = crypto.baseVolume; cryptoInfo.quoteVolume = crypto.quoteVolume; cryptoInfo.isFrozen = crypto.isFrozen; cryptoInfo.high24hr = crypto.high24hr; cryptoInfo.low24hr = crypto.low24hr; cryptoInfos.Add(cryptoInfo); } return(cryptoInfos); }
public void CryptoImageTest_FileInfo() { // Instance var instance = new CryptoImage(new FileInfo("sample/square.bmp")); // Test Condination Assert.IsInstanceOfType(instance, typeof(CryptoImage)); }
protected void Page_Load(object sender, EventArgs e) { try { string ID = (Request.QueryString["ID"] != null) ? Request.QueryString["ID"] : ""; string Type = (Request.QueryString["Type"] != null) ? Request.QueryString["Type"] : ""; if (Type == "Visitors") { dt = DBFun.FetchData("SELECT TOP 1 VisImage FROM VisitorsCard WHERE VisIdentityNo='" + ID + "' ORDER BY VisCardID DESC"); } if (Type == "VisitorsTmp") { dt = DBFun.FetchData("SELECT photo FROM TempImage WHERE Type = 'Visitors' AND EmpID ='" + ID + "'"); } if (Type == "Employee") { dt = DBFun.FetchData("SELECT image FROM EmployeeMaster WHERE EmpNationalID ='" + ID + "'"); } if (Type == "EmployeeTmp") { dt = DBFun.FetchData("SELECT photo FROM TempImage WHERE Type = 'Employee' AND EmpID ='" + ID + "'"); } if (Type == "Logo") { dt = DBFun.FetchData("SELECT AppLogo FROM ApplicationSetup"); } if (Type == "LogoTmp") { dt = DBFun.FetchData("SELECT photo FROM TempImage WHERE Type = 'Logo' AND EmpID ='" + ID + "'"); } //ReadImage if (DBFun.IsNullOrEmpty(dt)) { return; } if (Type == "Visitors" || Type == "Company" || Type == "Student" || Type == "Employee") { Response.BinaryWrite(CryptoImage.DecryptBytes((Byte[])dt.Rows[0][0])); Response.End(); } else { Response.BinaryWrite((Byte[])dt.Rows[0][0]); Response.End(); } } catch (Exception e1) { } }
public void MergeTest() { // Instance var instance = new CryptoImage(new FileInfo("sample/square.bmp")); // Test Modul instance.Merge(StringMock.StringItem); string expected = StringMock.StringItem; string actual = instance.String; // Test Condination Assert.AreEqual(expected, actual); }
public void CryptoImageTest_GetPixels() { // Instance var instance = new CryptoImage(new FileInfo("sample/square.bmp")); // Test Modul var actual = instance.Pixels; // Test Condination Assert.IsInstanceOfType(actual, typeof(List <Pixel>)); // Test Condination Assert.IsTrue(actual.Count > 0); }
public void SaveTest() { // Instance var instance = new CryptoImage(new FileInfo("sample/square.bmp")); // Test Modul instance.Merge(StringMock.StringItem); string expected = StringMock.StringItem; string actual = instance.String; // Test Condination Assert.AreEqual(expected, actual); // Thread SAFE System.Threading.Thread.Sleep(20); instance.Save(new FileInfo("sample/merged/square.text." + DateTime.Now.Ticks + ".bmp")); }
public void SeparateUTF8Test() { var instance = new Separator() .SourceType(SteganographyType.Image) .Source(new FileInfo("sample/merged/square.UTF8.text.bmp")) .SeparateType(SteganographyType.Text) .Separate(); // Test Condination Assert.IsInstanceOfType(instance, typeof(CryptoImage)); // Test Modul CryptoImage actual = (CryptoImage)instance; // Test Condination Assert.IsInstanceOfType(actual.String, typeof(string)); }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e) { string filePath = MapPath("~/App_Data/" + e.FileName); string fileContentType = e.ContentType; int fileSize = e.FileSize; string fileName = e.FileName; string path = MapPath("~/App_Data/" + e.FileName); AjaxFileUpload1.SaveAs(path); //e.PostedUrl = string.Format("?preview=1&fileId={0}", e.FileId); FileInfo fileInfo = new FileInfo(filePath); string ID = Path.GetFileNameWithoutExtension(path); // The byte[] to save the data in byte[] data = new byte[fileInfo.Length]; // Load a filestream and put its content into the byte[] using (FileStream fs = fileInfo.OpenRead()) { fs.Read(data, 0, data.Length); } byte[] EncryptData = CryptoImage.EncryptBytes(data); int EncryptfileSize = EncryptData.Length; System.Data.SqlClient.SqlConnection sqlConnection = new System.Data.SqlClient.SqlConnection(); sqlConnection.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["constring"].ConnectionString; String SqlCmdText1 = "UPDATE VisitorsCard SET VisImage =@VisImage,VisImageContentType=@VisImageContentType,VisImageLength=@VisImageLength WHERE VisIdentityNo = @VisIdentityNo"; System.Data.SqlClient.SqlCommand sqlCmdObj1 = new System.Data.SqlClient.SqlCommand(SqlCmdText1, sqlConnection); sqlCmdObj1.Parameters.Add("@VisIdentityNo", System.Data.SqlDbType.VarChar, 100).Value = ID; sqlCmdObj1.Parameters.Add("@VisImage", System.Data.SqlDbType.Binary, EncryptfileSize).Value = EncryptData; sqlCmdObj1.Parameters.Add("@VisImageContentType", System.Data.SqlDbType.VarChar, 255).Value = fileContentType; sqlCmdObj1.Parameters.Add("@VisImageLength", System.Data.SqlDbType.Int).Value = EncryptfileSize; sqlConnection.Open(); sqlCmdObj1.ExecuteNonQuery(); sqlConnection.Close(); }
public void SeparateTest() { // Instance var instance = new CryptoImage(new FileInfo("sample/merged/square.text.bmp")); var pixel = instance.BitmapImage.GetPixel(0, 0); // Instance var separator = new Core.Picture.Separator(pixel); // Test Modul int expected = PictureMock.SampleInt; int actual = separator.SeparateByte(); // Test Condination Assert.AreEqual(expected, actual); // Test Condination Assert.IsTrue(instance.String.Length == PictureMock.SampleInt); // Test Condination Assert.AreEqual(StringMock.StringItem, instance.String); }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void GetImage(out byte[] pImage, out string pImageContentType, out int pImageLength) { pImage = new Byte[0]; pImageContentType = ""; pImageLength = 0; string fileName = FindID() + ".jpeg"; string path = Server.MapPath(FindTempImagePath()) + fileName; bool available = System.IO.File.Exists(path); try { dt = DBFun.FetchData("SELECT * FROM TempImage WHERE Type = '" + Type + "' AND EmpID='" + FindID() + "'"); if (DBFun.IsNullOrEmpty(dt)) { if (available) { try { int len = System.IO.Path.GetFullPath(path).Length; byte[] imageData = new Byte[100000]; System.IO.FileStream newFile = new System.IO.FileStream(path, System.IO.FileMode.Open); newFile.Read(imageData, 0, imageData.Length); pImage = (byte[])imageData; pImageContentType = "image/pjpeg"; pImageLength = imageData.Length; } catch (Exception e1) { System.IO.File.Delete(path); } } else { DataTable imgdt = DBFun.FetchData(FindQuery()); if (!DBFun.IsNullOrEmpty(imgdt)) { if (!IsEncryption) { pImage = (Byte[])imgdt.Rows[0]["Image"]; } else { pImage = CryptoImage.DecryptBytes((Byte[])imgdt.Rows[0]["Image"]); } pImageContentType = imgdt.Rows[0]["ImageType"].ToString(); pImageLength = Convert.ToInt32(imgdt.Rows[0]["ImageLen"]); } } } else { pImage = (Byte[])dt.Rows[0]["photo"]; pImageContentType = dt.Rows[0]["PhotoType"].ToString(); pImageLength = Convert.ToInt32(dt.Rows[0]["PhotoLength"]); } int returnValue = DBFun.ExecuteData("DELETE FROM TempImage WHERE Type = '" + Type + "' AND EmpID='" + FindID() + "'"); } catch (Exception e2) { int returnValue = DBFun.ExecuteData("DELETE FROM TempImage WHERE Type = '" + Type + "' AND EmpID='" + FindID() + "'"); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void FillPropeties() { try { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); ProClass.DateType = FormSession.DateType; ProClass.VisCardID = txtVisCardID.Text; ProClass.VisIdentityNo = txtVisIdentityNo.Text; ProClass.VisNameAr = txtVisNameAr.Text; if (!string.IsNullOrEmpty(txtVisNameEn.Text)) { ProClass.VisNameEn = txtVisNameEn.Text; } if (!string.IsNullOrEmpty(txtVisMobileNo.Text)) { ProClass.VisMobileNo = txtVisMobileNo.Text; } ProClass.StartDate = calStartDate.getDate(); ProClass.ExpiryDate = calExpiryDate.getDate(); ProClass.VisRegion1 = chkbRegion.Items.FindByValue("Region1").Selected; ProClass.VisRegion2 = chkbRegion.Items.FindByValue("Region2").Selected; ProClass.VisRegion3 = chkbRegion.Items.FindByValue("Region3").Selected; ProClass.VisRegion4 = chkbRegion.Items.FindByValue("Region4").Selected; ProClass.VisRegion5 = chkbRegion.Items.FindByValue("Region5").Selected; ProClass.VisRegion6 = chkbRegion.Items.FindByValue("Region6").Selected; ProClass.VisRegion7 = chkbRegion.Items.FindByValue("Region7").Selected; ProClass.VisRegion8 = chkbRegion.Items.FindByValue("Region8").Selected; ProClass.VisRegion9 = chkbRegion.Items.FindByValue("Region9").Selected; if (!string.IsNullOrEmpty(txtDescription.Text)) { ProClass.Description = txtDescription.Text; } if (ddlTmpID.SelectedIndex > 0) { ProClass.TmpID = ddlTmpID.SelectedValue; } ProClass.CopiesCount = (Convert.ToInt16(FindCount(txtVisIdentityNo.Text)) + 1).ToString(); ProClass.CardStatus = "0"; ProClass.isPrinted = false; ProClass.TransactionBy = FormSession.LoginUsr; //////// Byte[] pImage = new Byte[0]; string pImageContentType = ""; int pImageLength = 0; VisImage.GetImage(out pImage, out pImageContentType, out pImageLength); if (pImageLength != 0) { ProClass.VisImage = CryptoImage.EncryptBytes(pImage); } else { ProClass.VisImage = pImage; } ProClass.VisImageContentType = pImageContentType; ProClass.VisImageLength = pImageLength; //////// } catch (Exception ex) { DBFun.InsertError(FormSession.PageName, "FillPropeties"); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void FillPropeties() { try { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); ProClass.DateType = FormSession.DateType; ProClass.EmpID = txtEmpIdentity.Text; ProClass.EmpType = ddlEmpType.SelectedValue; ProClass.EmpNameEn = txtEmpNameEn.Text; ProClass.EmpNameAr = txtEmpNameAr.Text; ProClass.EmpBirthDate = CalBirthDate.getDate(); ProClass.EmpJobTitleAr = txtJobTitleAr.Text; ProClass.EmpJobTitleEn = txtJobTitleEn.Text; ProClass.EmpNationalID = txtEmpNationalID.Text; ProClass.EmpHireDate = CalHireDate.getDate(); ProClass.EmpMobileNo = txtMobile.Text; ProClass.EmpEmailID = txtEmail.Text; if (ddlNatID.SelectedIndex > 0) { ProClass.NatID = ddlNatID.SelectedValue; } if (ddlBloodGroup.SelectedIndex > 0) { ProClass.EmpBloodGroup = ddlBloodGroup.SelectedValue; } if (ddlCompID.SelectedIndex > 0) { ProClass.CompID = ddlCompID.SelectedValue; } if (ddlSecID.SelectedIndex > 0) { ProClass.SecID = ddlSecID.SelectedValue; } if (rdlGender.SelectedIndex > -1) { ProClass.EmpGender = Convert.ToChar(rdlGender.SelectedValue); } ProClass.TransactionBy = FormSession.LoginUsr; ProClass.TransactionDate = DateTime.Now.ToShortDateString(); ////////////////////////////////////////////// Byte[] pImage = new Byte[0]; string pImageContentType = ""; int pImageLength = 0; EmpImage.GetImage(out pImage, out pImageContentType, out pImageLength); if (pImageLength != 0) { ProClass.EmpImage = CryptoImage.EncryptBytes(pImage); } else { ProClass.EmpImage = pImage; } ProClass.EmpImageContentType = pImageContentType; ProClass.EmpImageLength = pImageLength; ////////////////////////////////////////////// } catch (Exception Ex) { DBFun.InsertError(FormSession.PageName, "FillPropeties"); MessageFun.ShowAdminMsg(this, Ex.Message); } }