gpt4 book ai didi

openssl - 关于使用 RC4 使用十六进制 key 加密文件的问题

转载 作者:行者123 更新时间:2023-12-01 02:44:14 25 4
gpt4 key购买 nike

我必须使用 RC4 算法为我的脚本加密一个二进制文件(用 bash 编写)

key 也是二进制格式

以下是我正在做的事情:

    echo -n -e $bPacketh > /tmp/packet
echo -n -e $clientWriteKeyb > /tmp/cwkey
mach=`openssl dgst -binary -hmac -md5 /tmp/cwkey /tmp/packet`
pkth=`openssl enc -e -rc4 -K /tmp/cwkey -in /tmp/packet`

/tmp/packet 和/tmp/cwkey 的内容如下:
    >cat /tmp/packet | od -t x1

0000000 86 09 94 8b cf 2d d3 99 94 9f 72 60 dd 3f a6 b6
0000020 01 00 00 00 13 0b 05 00 00 00 0c 73 73 68 2d 75
0000040 73 65 72 61 75 74 68 22 68 fb ab 5e 4d 1b 2b 61
0000060 bd 38
0000062

>cat /tmp/cwkey | od -t x1

0000000 5d c5 45 a8 2b 44 5d 2f 49 67 f5 71 73 a8 51 5c
0000020

MAC计算命令成功,但是加密包计算命令报错如下:
    >openssl enc -e -rc4 -K /tmp/cwkey -in /tmp/packet

non-hex digit
invalid hex key value

我搜索了论坛,发现 key 的格式应该是“0001020304...”,但我不确定如何将我的 key (上面的/tmp/cwkey)转换为该格式

请您帮帮我

最佳答案

要获得 od 以该格式提供的内容:

od -t x1 | cut -d' ' -f2- | head -n -1 | tr "\n" ' ' | tr -d ' ' 

英文:获取十六进制转储,切出每行的第一个字段(计数),切掉最后一行,将剩余的换行符更改为空格,然后删除所有空格。

关于openssl - 关于使用 RC4 使用十六进制 key 加密文件的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7331716/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com