【发布时间】:2020-02-22 09:49:58
【问题描述】:
我在树莓派上构建了一个二维码扫描器。我希望数据偏移量由用户设置的所需 ascii 值,以便数据有点隐藏。我希望表示的唯一 ascii 值是可打印字符 32-126。 我的问题 - 例如,我希望输入偏移量为 1 的 hello。这将表示为“ifmmp”。这并不麻烦,但如果我希望表示更接近 ascii 值 126 的值,我会在获得扩展的 ascii 字符时遇到问题 - 这不是我的意图。
希望你能帮忙
提前致谢
# the barcode data is a bytes object so if we want to draw it
# on our output image we need to convert it to a string first
barcodeData = barcode.data.decode("ascii")
#Change the decoded ascii string by a value of desired charcters
barcodeData = "".join(chr(ord(c) - 5) for c in barcodeData)
【问题讨论】:
-
一种常见的排列方式是环绕使得 126+1=32 等;但如何定义这取决于您。
-
@tripleee 感谢您的回复,我将如何暗示?
-
提示:减法、取模、加法;谷歌凯撒密码。
标签: python raspberry-pi ascii offset