private void CheckSignature() { try { ResetStatus(); var signer = new SimpleHashSigner(new LsbEncoder()); using (var image = (Bitmap)Image.FromFile(SignedImagePath, true)) { var result = signer.ValidateSignature(image); SetStatus(result.SignatureIsValid); // сохраняем изображение с пометками проверки var path = Path.Combine( Path.GetDirectoryName(UnsignedImagePath), string.Format("{0}_{1}_{2}{3}", Path.GetFileNameWithoutExtension(UnsignedImagePath), "INVALID_SIGNATURE", GetTimeStamp(), Path.GetExtension(UnsignedImagePath)) ); result.ImageWithValidationMarks.Save(path); Process.Start(path); } } catch (Exception e) { SetStatus(false); System.Windows.MessageBox.Show(e.Message); } }
private void Sign() { try { var signer = new SimpleHashSigner(new LsbEncoder()); using (var image = (Bitmap)Image.FromFile(UnsignedImagePath, true)) { var newImg = signer.Sign(image); var newPath = Path.Combine(Path.GetDirectoryName(UnsignedImagePath), string.Format("{0}_{1}_{2}{3}", Path.GetFileNameWithoutExtension(UnsignedImagePath), "SIGNED", GetTimeStamp(), Path.GetExtension(UnsignedImagePath)) ); newImg.Save(newPath); SignedImagePath = newPath; } } catch (Exception e) { System.Windows.MessageBox.Show(e.Message); } }