css 颤动_用颤动隐藏图像加密隐写术中的数据

css 颤动

Steganography is the practice of concealing messages (e.g. text, raw bytes, or images) within other types of media (e.g. images, videos, or files). For example, hiding a piece of text inside an image.

隐秘术是在其他类型的媒体(例如图像,视频或文件)中隐藏消息(例如文本,原始字节或图像)的做法。 例如,在图像内隐藏一段文本。

隐写术有助于减少解密尝试和审查 (Steganography Helps Reduce Decryption Attempts and Censorship)

As social media reaches deeper inside our daily communication, privacy issues have raised concerns. A common practice is to encrypt messages, but encrypted messages are easily identifiable. Although SHA-256 encryption is almost impossible to crack, with social engineering, passwords can still be compromised. Also, messaging services are vulnerable to censorship.

随着社交媒体深入我们的日常交流,隐私问题引起了人们的关注。 常见的做法是对消息进行加密,但是很容易识别加密的消息。 尽管SHA-256加密几乎不可能破解,但是通过社会工程学,仍然可以破坏密码。 此外,消息传递服务容易受到审查。

A better approach is to hide the encrypted message with steganography. There won’t be any attempts to attack/block if there’s no message—or at least if there appears to be no message.

更好的方法是使用隐写术隐藏加密的消息。 如果没有消息,或者至少没有消息,则不会尝试攻击/阻止。

Let’s implement encrypted steganography step by step with Flutter.

让我们使用Flutter逐步实现加密隐写术。

想法是将字节秘密编码为图像 (The Idea Is to Encode Bytes Into Images Secretly)

As we know, images consist of pixels, and each pixel usually consists of three eight-bit integers.

众所周知,图像由像素组成,每个像素通常由三个八位整数组成。

To hide information into a pixel, we must change at least one bit.

要将信息隐藏到像素中,我们必须至少更改一位。

In order to make it unnoticeable, we choose to modify the least significant bit, preserving the major portion of the pixel value.

为了不引起注意,我们选择修改最低有效位,保留像素值的主要部分。

For example, if the value of a pixel is 173 (which is 0b10101101 in its binary form) and the bit we want to hide in this pixel is 0b0, we simply need to replace the least significant bit with 0b0. This results in a new pixel value of 0b10101100 whose decimal value is 172 (not far from the original value of 173).

例如,如果一个像素的值为173(二进制形式为0b10101101 ),而我们要隐藏在该像素中的位为0b0 ,则只需将最低有效位替换为0b0 。 这将导致新的像素值0b10101100其十进制值为172(距离原始值173不远)。

With this approach, the image with the message will be indistinguishable to human eyes (or by machines if the original image is complex).

通过这种方法,带有消息的图像对于人眼是无法区分的(如果原始图像很复杂,则无法通过机器识别)。

Before we start, let’s first take a sneak peek at the completed app:

在开始之前,我们先来偷看一下已完成的应用程序:

步骤1:初始化应用 (Step 1: Initialize an App)

Initializing a Flutter app is straightforward with the command flutter create awesome_encrypted_steganography_app. After the app is initialized, we can add the following into pubspec.yml as dependencies:

使用flutter create awesome_encrypted_steganography_app命令flutter create awesome_encrypted_steganography_app初始化Flutter应用程序。 应用初始化之后,我们可以将以下pubspec.yml作为依赖项添加到pubspec.yml中:

image_picker: ^0.6.3+1              # Used to upload images
image_gallery_saver: ^1.2.2 # Used to output images
esys_flutter_share: ^1.0.2 # Used to share images
image: # Used for image manipulation
permission_handler: ^4.2.0+hotfix.3 # Used to handle permissions
encrypt: ^4.0.0 # Used to do AES encryption
provider: ^4.0.4 # Used to provide services

步骤2:草绘屏幕 (Step 2: Sketch Out Screens)

To summarize, we need five screens to build an end-to-end encrypted steganography app:

总而言之,我们需要五个屏幕来构建端到端的加密隐秘应用程序:

  • A home screen where users can select either to encode a message into an image or decode a message from an image.

    主屏幕,用户可以选择将消息编码为图像或从图像解码消息。
  • A screen to support the encoding flow where users can upload an image and type in the message and the token for encryption.

    一个支持编码流程的屏幕,用户可以在其中上传图像并键入消息和令牌以进行加密。
  • A screen to output the encoded image and let users download/share the result.

    屏幕输出编码的图像,并允许用户下载/共享结果。
  • A screen to support the decoding flow where users can upload an image and type in the token for decryption.

    一个支持解码流程的屏幕,用户可以在其中上传图像并键入令牌进行解密。
  • A screen to show the decoded and decrypted message.

    显示解码和解密消息的屏幕。

Note: As UI is not the focus of this piece, please see the repository for implementation details if interested.

注意:由于UI不是本文的重点,因此如果有兴趣,请参见存储库以获取实现细节。

Let’s jump to the completed UI to get an idea of how the app functions.

让我们跳到完整的UI,以了解应用程序的功能。

消息到图像流 (The message-to-image flow)

Image for post

图像到消息流 (The image-to-message flow)

Image for post

步骤3:将消息加密和编码为图像 (Step 3: Encrypt and Encode Messages Into Images)

Here is a diagram showing the simplified implementation:

这是显示简化实现的图:

Image for post

加密消息 (Encrypt the message)

Here, we will use AES to do symmetric encryption because the receiver needs to decrypt the original message (SHA256 hashes are not recoverable):

在这里,我们将使用AES进行对称加密,因为接收方需要解密原始消息(SHA256哈希不可恢复):

将加密的消息转换为位 (Convert the encrypted message to bits)

Then we need to convert String messages to bits by shifting right and masking the last bit eight times:

然后,我们需要通过右移并屏蔽最后一位八次来将String消息转换为位:

将每一位编码为一个像素 (Encode each bit into a pixel)

As described above, we will encode bits into images by replacing the least significant bit of each pixel value:

如上所述,我们将通过替换每个像素值的最低有效位来将位编码为图像:

步骤4:从图片中恢复邮件 (Step 4: Recover Messages From Images)

Image for post

从图像像素中恢复位 (Recover bits from image pixels)

To extract bits from the pixels, we need to mask the least significant bit of each pixel:

要从像素中提取位,我们需要屏蔽每个像素的最低有效位:

从位中恢复加密的消息 (Recover the encrypted message from bits)

To assemble bytes from bits, we can simply concatenate eight bits together:

要从位组合字节,我们可以简单地将八个位连接在一起:

解密消息 (Decrypt the message)

The code to encrypt/decrypt symmetric encryption is standard and symmetric too, so the decryption code looks pretty much the same as encryption code:

加密/解密对称加密的代码也是标准的和对称的,因此解密代码看起来与加密代码几乎相同:

步骤5:喝杯咖啡 (Step 5: Have a Cup of Coffee)

Hooray! Now you have learned how to implement an encrypted steganography app from scratch. Happy hacking and let’s protect our privacy!

万岁! 现在,您已经学习了如何从头开始实现加密的隐秘应用程序。 祝您黑客愉快,并保护我们的隐私!

翻译自: https://medium.com/better-programming/hide-data-in-images-encrypted-steganography-with-flutter-43b76ed5241f

css 颤动

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值