使用带有零填充和原始数据的命令行使用openssl des-ede进行解密 [英] Decrypting using openssl des-ede from the command-line with zero padding and raw data
问题描述
$ key ='aaaaaaaabbbbbbbccccccccdddddddd';
$ key = pack('H *',$ key);
$ data ='b5057bbc04b842a96144a0f617f2820e';
$ data = pack('H *',$ data);
$ result = openssl_decrypt($ data,'des-ede',$ key,OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING);
我正在使用的命令(Ubuntu)
openssl des-ede -in encrypted-data.txt -out decrypted-data.txt -d -K aaaaaaaabbbbbbbccccccccdddddddd -nopad
/ p>
密钥
我解密的密钥是十六进制值: code> aaaaaaaabbbbbbbbccccccccdddddddd 。这个密钥可以以十六进制形式传递吗?
加密数据
我传递在encrypted-data.txt文件中的数据是十六进制值: b5057bbc04b842a96144a0f617f2820e
。数据应解密为 Test123123
。我已经尝试将加密数据转换为二进制文件,并将其传递到.bin文件中,而无需成功。这些数据在传递之前是否应该转换成其他格式?
参数
我相信我有一个问题来翻译php参数 OPENSSL_RAW_DATA
和 OPENSSL_ZERO_PADDING
到我的命令行调用。我发现选项 -nopad
,但不确定它是否等同于php中的选项
我只是在这里,因为我无法格式化评论,这个问题应该被关闭和删除。这将通过命令行 openssl
实用程序验证进程的工作原理。
pvg / tmp➤more e.php
<?php
$ data ='b5057bbc04b842a96144a0f617f2820e';
$ data = pack('H *',$ data);
echo $ data;
pvg / tmp➤php e.php>在
pvg / tmp➤openssl des-ede -in in -out out -d -K aaaaaaaabbbbbbbccccccccdddddddd -nopad
pvg / tmp➤cat out
Test123123%
I am trying to recreate some openssl php code in the command-line. I have been able to get the following php code to work:
$key = 'aaaaaaaabbbbbbbbccccccccdddddddd';
$key = pack('H*',$key);
$data = 'b5057bbc04b842a96144a0f617f2820e';
$data = pack('H*',$data);
$result = openssl_decrypt($data,'des-ede', $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING);
The Command I'm Working on (Ubuntu)
openssl des-ede -in encrypted-data.txt -out decrypted-data.txt -d -K aaaaaaaabbbbbbbbccccccccdddddddd -nopad
The Key
The key that im decrypting with is the hex value: aaaaaaaabbbbbbbbccccccccdddddddd
. Can this key be passed as hex?
The Encrypted Data
The encrypted data I am passing in the encrypted-data.txt file is the hex value: b5057bbc04b842a96144a0f617f2820e
. The data should decrypt to Test123123
. I have tried converting the encrypted data to binary and passing it through a .bin file without success. Should this data be converted to some other format before being passed?
The Parameters
I believe I am having an issue translating the php parameters OPENSSL_RAW_DATA
and OPENSSL_ZERO_PADDING
to my command-line call. I have discovered the option -nopad
, but am unsure if it is equivalent to the options in php
I'm only including this here since I can't format a comment and this question should probably be closed and deleted. This verifies the process works identically with the command line openssl
utility
pvg /tmp ➤ more e.php
<?php
$data = 'b5057bbc04b842a96144a0f617f2820e';
$data = pack('H*',$data);
echo $data;
pvg /tmp ➤ php e.php > in
pvg /tmp ➤ openssl des-ede -in in -out out -d -K aaaaaaaabbbbbbbbccccccccdddddddd -nopad
pvg /tmp ➤ cat out
Test123123%
这篇关于使用带有零填充和原始数据的命令行使用openssl des-ede进行解密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!