linux命令行使用hmac-sha1对中间带多个空格的字符串进行带key的校验
时间: 2024-03-09 22:48:54 浏览: 236
使用以下命令可以在Linux命令行中使用hmac-sha1对中间带多个空格的字符串进行带key的校验:
```
echo -n "your string with spaces" | openssl dgst -sha1 -hmac "your key" -hex
```
其中,`echo -n "your string with spaces"` 用于输出待校验的字符串, `-n` 参数表示输出时不自动添加换行符。
`openssl dgst` 命令用于计算散列值, `-sha1` 参数表示使用SHA1算法, `-hmac "your key"` 参数表示使用指定的key进行计算, `-hex` 参数表示输出结果以16进制格式显示。
注意,这里的字符串中间带多个空格需要用引号括起来。
相关问题
linux命令行使用hmac-sha1对中间带多个换行符的字符串进行带key的校验
可以使用以下命令在Linux命令行中使用hmac-sha1对中间带多个换行符的字符串进行带key的校验:
```
printf 'your\nstring\nwith\nnewlines\n' | openssl dgst -sha1 -hmac "your key" -hex
```
其中,`printf` 命令用于输出待校验的字符串,字符串中的换行符可以使用 `\n` 进行表示。
`openssl dgst` 命令用于计算散列值, `-sha1` 参数表示使用SHA1算法, `-hmac "your key"` 参数表示使用指定的key进行计算, `-hex` 参数表示输出结果以16进制格式显示。
需要注意的是,在使用 `printf` 命令时需要使用单引号将字符串括起来,以免换行符被解释为命令的结束符。
linux 命令行使用hmac-sha1对字符串进行带key的加密
可以使用openssl命令行工具进行hmac-sha1加密。以下是示例命令:
```
echo -n "string to be encrypted" | openssl dgst -sha1 -hmac "yourkey"
```
其中,`echo -n "string to be encrypted"`表示要加密的字符串,`yourkey`表示密钥。运行上述命令后,会输出加密后的结果。
阅读全文
相关推荐
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![gz](https://img-home.csdnimg.cn/images/20210720083447.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![gz](https://img-home.csdnimg.cn/images/20210720083447.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)