皆さんの助けを借りて、私は非常に単純な画像暗号化装置を作成しました。非技術者を締め出すには十分ですよね?:P
次のステップに進みます。誰かが XOR の使用を提案しました。XOR について読みましたが、これは基本的に、2 つのビットの間の答えを決定する論理テーブルですよね?
いずれかが真の場合にのみ、ステートメントは真です。
0 0 = 偽 1 0 = 真 0 1 = 真 1 1 = 偽
これは正しいです?では、画像を XOR 暗号化するにはどうすればよいでしょうか。
これは、シーザー暗号を使用した以前の方法です。
private void EncryptFile()
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.Filter = "JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif";
dialog.InitialDirectory = @"C:\";
dialog.Title = "Please select an image file to encrypt.";
byte[] ImageBytes;
if (dialog.ShowDialog() == DialogResult.OK)
{
ImageBytes = File.ReadAllBytes(dialog.FileName);
for (int i = 0; i < ImageBytes.Length; i++)
{
ImageBytes[i] = (byte)(ImageBytes[i] + 5);
}
File.WriteAllBytes(dialog.FileName, ImageBytes);
}
}
private void DecryptFile()
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.Filter = "JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif";
dialog.InitialDirectory = @"C:\";
dialog.Title = "Please select an image file to decrypt.";
byte[] ImageBytes;
if (dialog.ShowDialog() == DialogResult.OK)
{
ImageBytes = File.ReadAllBytes(dialog.FileName);
for (int i = 0; i < ImageBytes.Length; i++)
{
ImageBytes[i] = (byte)(ImageBytes[i] - 5);
}
File.WriteAllBytes(dialog.FileName, ImageBytes);
}
}