Home > openssl > Decode file encoded on one system using openssl on another system

# Decode file encoded on one system using openssl on another system

January 29Hits:2

I am encrypting a file on Ubuntu machine with openSSL using following command:

openssl enc -aes-256-cbc -in mydbBackup.tar -out  mydbBackup.enc.tar       -pass pass:scecret 


I transfer it to ftp server. Now when I copy the file from ftp to another machine and try to decrypt it with following command:

openssl enc -aes-256-cbc -d -in mydbBackup.tar -out  mydbBackup.enc.tar       -pass pass:scecret 


I get following error:

bad decrypt 139727625037472:error:06065064:digital envelope routines:EVP_DecryptFinal_ex: bad decrypt:evp_enc.c:467: 


Is it some problem due to file transfer or is it not possible to decrypt the files encrypted on another system?

EDIT:-

I have executed ls -l command after running decrypt command with (-out decrypt.tar.gz) and without (-out decrypt.tar.gz) salt argument and I get following output:

-rw-r--r-- 1 backup backup 43119360 2012-01-29 07:10 encrypt-20120128.enc.tar.gz -rw-r--r-- 1 backup backup 43119328 2012-01-29 07:12 decrypt1.tar.gz -rw-r--r-- 1 backup backup 43119328 2012-01-29 07:12 decrypt.tar.gz 


so it is churning out something but it is throwing up error and tar complains that resulting file is not gzip archive.

UPDATE:- I have calculated MD5 checksum (as suggested by @Oliver Salzburg) of original file and one transferred from ftp and surprisingly it gives same value for both the files.

21b95cb2431c5d61c93fe642d63ca7d0 


In general, a file encrypted like this should be decryptable on another system (I just tested it just to make sure).

So either the file is "broken" or there is something else conflicting with the decryption. But I could only make assumptions about that. I remember an issue similar to this caused by transferring a key/certificate as text. The resulting file had a BOM attached to it which caused problems with the encryption/decryption process (it was also converted to Unicode which didn't help either).

The command should be:

openssl enc -aes-256-cbc -d -in mydbBackup.enc.tar -out mydbBackup.tar
-pass pass:scecret



As Oliver mentioned, the in/out for decryption is the opposite of the in/out of encryption.

also put the .enc last as a convention, the first layer of the "onion" is the encrypted data, not the tarred data.

Tags:openssl

## Related Articles

• ### Decode file encoded on one system using openssl on another systemJanuary 29

I am encrypting a file on Ubuntu machine with openSSL using following command: openssl enc -aes-256-cbc -in mydbBackup.tar -out mydbBackup.enc.tar -pass pass:scecret I transfer it to ftp server. Now when I copy the file from ftp to another machine an

• ### Change global system property for file.encodingJanuary 20

Due to a conflict between the mac osx lion 'file.encoding' system-property and my java application, i have to change the setting from MacRoman to UTF-8. What is the best way to reset this system property globally for all users on this machine? Regard

• ### Decoding URL encoding (percent encoding)October 4

I want to decode URL encoding, is there any built-in tool for doing this or could anyone provide me with a sed code that will do this? I did search a bit through unix.stackexchange.com and on the internet but I couldn't find any command line tool for

• ### How can I encode and decode percent-encoded strings on the command line?July 19

How can I encode and decode percent-encoded (URL encoded) strings on the command line? I'm looking for a solution that can do this: $percent-encode "ændrük" %C3%A6ndr%C3%BCk$ percent-decode "%C3%A6ndr%C3%BCk" ændrük --------------Sol

• ### Will a file encoded with the libx264 play on Windows 8?November 6

I'm sending a movie via email. Will a file encoded with the ffmpeg's option libx264, be able to play back natively in Windows 8 without any external software? ffmpeg -i in.avi -vcodec libx264 out.avi --------------Solutions------------- TL;DR: Window

• ### Umlauts in a JabRef managed BibTeX file and file encodingNovember 6

When I have Umlauts in my BibTex file then I learned that it should be inserted as H{\"o}ckel The problem with this approach is, that inside the JabRef preview or when I export the database to e.g. html, it is still displayed as LaTeX code and not as

• ### How does the Java VM determine its default file.encoding?December 13

I'm running a Java program on Mac OS X 10.8 (from the Terminal), and the Java VM's file.encoding is defaulting to "SJIS". I even tried a tiny Java program that does nothing but print out the system properties, and that shows that the Java VM its

• ### Decoding and Encoding packet layers using decorator patternAugust 2

I am trying to use decorator pattern to decode and encode packet layers in my application. I've supposed my packet has three layers: Header, Level2, Level3. So far I've come up with the following code. For the sake of simplicity, I've supposed that t

• ### Arithmetic coding - unable to decode after encodingJanuary 17

This is for a school project and I am asked to implement an arithmetic coding and decoding algorithm. I mostly followed the algorithm structure in this youtube video and this other video. If you have links to other tutorials for arithmetic coding I w

• ### In Windows 7, what is the System Path to the Mute system file?February 7

I need the direct path to the system file, not a way to make a shortcut or hotkey. The reason I need this, is because I am using S-Bar on my MSI laptop, and I can designate one of my custom laptop keys to be whatever I want it to open. It asks for a

• ### file, awk and iconv to automatically adapt tex-file encodingApril 17

I have a set of tex-files with mixed encodings, e.g. (subset of output of file -i *.tex) f1.tex: text/plain; charset=utf-8 f2.tex: text/plain; charset=utf-8 f3.tex: text/x-tex; charset=us-ascii f4.tex: text/plain; charset=iso-8859-1 f5.tex: text/plai

• ### File Encoding and Input EncodingApril 24

In order to avoid cluttering other related questions, I separately make this question. If I use Notepad as my editor, there are 4 encoding options available when saving the TeX input file: ANSI, Unicode, Unicode big endian, and UTF-8. I want to know

• ### Disabling File Encoding in ReportsJuly 24

Iam looking to disable File encoding option while exproting reports in salesforce How to disable that.? --------------Solutions------------- This is one of those UI elements that are outside an administrator's ability to customize. I would suggest th

• ### Which file in kernel specifies fork(), vfork()- to use sys_clone() system callAugust 21

When ltrace is used for tracing the system calls, I could see that fork() uses sys_clone() rather than sys_fork(). But I couldnt find the linux source where it is defined. My program is #include<stdio.h> main() { int pid,i=0,j=0; pid=fork(); if(pid=

• ### How to take the executable file of the particular software and install in other system?January 20

How to take the executable file of the particular software and install in other system like we tacking back up in android applications --------------Solutions------------- This answer helps if you only need to move eclipse to another computer, with s

• ### Way to decode an encoded payload June 7

I am facing an XSS vulnerability in my ASP.Net Web application where the malicious code may be encrypted and html encoded Bottomline: I am trying to prevent XSS via code obfuscation. Question: I already know that I have to use HtmlDecode anyway.Is th

• ### Does using ASCII transfer mode in FTP while transferring files from one linux based system to other linux based system changes LF to CRLF August 26

This question is an exact duplicate of: Line terminators not being converted as desired in ASCII Transfer mode [closed] Whether using ASCII transfer mode in FTP while transferring files from one linux based system to other linux based system changes

• ### File-encoding issues with \lstinputlistingDecember 12

Matlab save .m file with ANSI encoding. I have a sample .m file, and want import it into LaTeX with UTF-8 encoding. How to convert ANSI file encoding to UTF-8 and input it, without changing the original file? \documentclass{article} \usepackage{listi

• ### Convert Text File EncodingApril 14

I frequently encounter text files (such as subtitle files in my native language, Persian) with character encoding problems. These files are created on Windows, and saved with an unsuitable encoding (seems to be ANSI), which looks gibberish and unread

• ### Enabling UTF-8 file encoding in various text editors May 11

Many IDE / text editors used by latex community do not encode tex files into utf-8 by default. When trying to use diacritics, various issues may arise. Example code: \documentclass{article} \usepackage[utf8]{inputenc} \begin{document} Denis Bogdănaş