mirror of
https://github.com/Finb/Bark.git
synced 2026-04-26 06:25:55 +03:00
[GH-ISSUE #192] 在加密情况下,是不是有字符限制,超过15个字符就失败了 #174
Labels
No labels
bug
enhancement
in progress
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/Bark#174
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @MoncozGC on GitHub (Apr 14, 2023).
Original GitHub issue: https://github.com/Finb/Bark/issues/192
rt,不清楚是这样的限制还是我配置的有问题。
@Finb commented on GitHub (Apr 14, 2023):
我测试几百个字符都是没问题的,可以给我一个测试用例我测试下
@MoncozGC commented on GitHub (Apr 14, 2023):
我隐藏了bark key, 加密key和iv;
body中的message是通过参数传递的,这样应该不会有影响吧,我打印了json内容看着是没有问题的
@Finb commented on GitHub (Apr 14, 2023):
把JSON打印一下,找个工具验证下JSON格式是否正确
@MoncozGC commented on GitHub (Apr 14, 2023):
JSON字符串解析没有问题,应该还是字符的长度的问题。
@Finb commented on GitHub (Apr 14, 2023):
第二个json我这是可以正常发的
你提供一个完整的发送脚本发我吧,隐藏掉deviceKey,保留加密key或IV
@MoncozGC commented on GitHub (Apr 14, 2023):
好的
@Finb commented on GitHub (Apr 14, 2023):
测试没问题
第一个JSON,加密后的密文是 “10tJijOcbS5126u7Wg4Ct+dQzUfJIKDI1BqTvspzmFgIYECwhcb1R3wVk1pOJFM6ZpKuVzHG0MApY3dWO+jq4Q==”
@MoncozGC commented on GitHub (Apr 14, 2023):
很奇怪,我的加密出来再某一个地方有空格
我测试了一下,在json字符串过长的时候就会多一个空格,这样就导致在解密的时候有问题,应该是这个问题导致的。
@MoncozGC commented on GitHub (Apr 14, 2023):
我通过下面的方式解决了问题,我是在windows环境使用git bash 执行的,可能在base64命令执行的时候会输入换行符。
通过下面的命令删除换行符就可以了
@Finb commented on GitHub (Apr 14, 2023):
base64 出现换行符应该是不正常的
@MoncozGC commented on GitHub (Apr 14, 2023):
是的,可能是环境的问题吧,感谢帮助~
@rustle123 commented on GitHub (Aug 31, 2023):
我这边测试出来的结果也是这样,请问后来发现是哪里的问题了吗?我感觉我的环境没啥问题的..... @Finb @MoncozGC
我这边是这样的,第一个json可以正常接受,第二个就提示Decryption failed.....
json='{"body": "do", "sound": "birdsong"}'
json='{"title": "hell", "body": "do", "sound": "birdsong"}'
@MoncozGC commented on GitHub (Aug 31, 2023):
这是用的同一个KEY发送的消息嘛,我用了你的两条消息都可以正常发送出去。
我当时的问题是加密出来的密文再某一个地方有空格,利用这个命令解决的
ciphertext=$(echo -n "$json" | openssl enc -aes-128-cbc -K $key -iv $iv | base64 | tr -d '\n')
@rustle123 commented on GitHub (Aug 31, 2023):
是的,我找到了解决办法,观察bash脚本加密后的输出,内容较长的时候,加密内容就会有空格,比如:
此时,ciphertxt就是:
中间是有空格的,使用
tr -d ' '命令把空格删除在发送,就可以了感谢!
@cfbsks commented on GitHub (Oct 2, 2023):
关于长json导致未知的空格问题, 通过man base64可以得到问题原因,
即为了方便屏幕阅读, base64命令默认启用了76字符后换行, 也就产生了空格符.
要解决此问题, 可以添加
-w 0选项, 取消默认换行操作.ciphertext=$(echo -n "$json" | openssl enc -aes-128-cbc -K $key -iv $iv | base64 -w 0)