dsfs5420 2016-12-23 19:16 采纳率: 100%
浏览 480
已采纳

使用openssl des-ede从命令行解密,零填充和原始数据

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

  • 写回答

1条回答 默认 最新

  • donglengli0644 2016-12-23 21:06
    关注

    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%    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置