How to decrypt a file in UNIX?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users How to decrypt a file in UNIX?
# 8  
Old 08-23-2013
Quote:
Originally Posted by hergp
As I said, openssl is a little picky, every encoded line (except the last one) has to be 64 characters long.

Code:
Q2xhaW1OdW1iZXIsQ2xhaW1EZWFsVHlwZSxSZWplY3Rpb25SZWFzb24sRGVhbE51
bWJlcixTYWxlc09yZGVyTnVtYmVyLEhQU2FsZXNPcmRlck51bWJlcixJbnZvaWNl
RGF0ZSxJbnZvaWNlTnVtYmVyLFNLVSxRdWFudGl0eSxTZXJpYWxOdW1iZXIsQmls
bFRvTmFtZSxFVXNlck5hbWUsQmlsbFRvQWRkcmVzczEsQmlsbFRvQWRkcmVzczIs
QmlsbFRvQ2l0eSxCaWxsVG9TdGF0ZSxCaWxsVG9aaXBDb2RlLFNoaXBUb05hbWUs
U2hpcFRvQWRkcmVzczEsU2hpcFRvQWRkcmVzczIsU2hpcFRvQ2l0eSxTaGlwVG9T
dGF0ZSxTaGlwVG9aaXBDb2RlLEVuZFVzZXJOYW1lLEVuZFVzZXJBZGRyZXNzMSxF
bmRVc2VyQWRkcmVzczIsRW5kVXNlckNpdHksRW5kVXNlclN0YXRlLEVuZFVzZXJa
aXBDb2RlLEJhdGNoTnVtYmVyLENvbXBhbnlMb2NhdGlvbklELERpc3RyaWJ1dG9y
TmFtZQ0KIkMxMjQ1MzIiLCJWb2x1bWUgSFBOIFN3aXRjaGluZyBSb3V0aW5nIEFw
cGxpY2F0aW9ucyBBY2Nlc3NvcmllcyBOQk8iLCIiLCJENzIxNzU4IiwiIiwiIiwi
OC8xLzIwMTMgMTI6MDA6MDAgQU0iLCI0MDI1NjE0MTEiLCJKOTcyN0EjQUJBIiwi
MiIsIiIsIkNBTUVSQSBDT1JORVIgQ09OTkVDVElORyBQT0lOVCIsIkJBREdFUiBT
SEVFVCBNRVRBTCIsIkdFIENPTU1FUkNJQUwgRElTVFJJQlVUSU9OIEZJTiBDT1JQ
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iwiOC8yLzIwMTMgMTI6MDA6MDAgQU0iLCIzMjE3Mzc4MjEiLCJEOEU2NlVUI0FC
QSIsIjExIiwiIiwiTkVUR0FJTiBURUNITk9MT0dJRVMgSU5DIiwiQ0VOVEVSUyBG
T1IgWU9VVEggJiBGQU1JTElFUyIsIlBPIEJPWCAyNTE5NzAiLCIiLCJMSVRUTEUg
Uk9DSyIsIkFSIiwiNzIyMjUxOTcwIiwiQ0VOVEVSUyBGT1IgWU9VVEggJiBGQU1J
TElFUyIsIjY1MDEgVyAxMlRIIFNUIiwiIiwiTElUVExFIFJPQ0siLCJBUiIsIjcy
MjA0MTUxMSIsIkNFTlRFUlMgRk9SIFlPVVRIICYgRkFNSUxJRVMiLCI2NTAxIFcg
MTJUSCBTVCIsIiIsIkxJVFRMRSBST0NLIiwiQVIiLCI3MjIwNDE1MTEiLCIyNDIy
IiwiMTAwMjYyNDIiLCJJbmdyYW0gTWljcm8gLSAxMDAyNjI0MiIsDQ==

Thanks,its working & i am able to see the actual data but is there any way to see the actual data without resizing it to 64? Since that needs to be done manually,but i dont want to do it manually for every file.....
# 9  
Old 08-23-2013
There are other tools, like base64 from GNU coreutils, and also quite a few online decoders, like http://www.base64decode.org/. If your files are not too big, the online decoders might be useful.

Last edited by hergp; 08-23-2013 at 05:09 AM..
# 10  
Old 08-23-2013
On my recent Linux:
Code:
base64 -d file
ClaimNumber,ClaimDealType,RejectionReason,DealNumber,SalesOrderNumber,HPSalesOrderNumber,InvoiceDate,InvoiceNumber,SKU,Quantity,SerialNumber,BillToName,EUserName,BillToAddress1,BillToAddress2,BillToCity,BillToState,BillToZipCode,ShipToName,ShipToAddress1,ShipToAddress2,ShipToCity,ShipToState,ShipToZipCode,EndUserName,EndUserAddress1,EndUserAddress2,EndUserCity,EndUserState,EndUserZipCode,BatchNumber,CompanyLocationID,DistributorName
"C124532","Volume HPN Switching Routing Applications Accessories NBO","","D721758","","","8/1/2013 12:00:00 AM","402561411","J9727A#ABA","2","","CAMERA CORNER CONNECTING POINT","BADGER SHEET METAL","GE COMMERCIAL DISTRIBUTION FIN CORP","DEALER #108250","WILLIAMSVILLE","NY","142210000","BADGER SHEET METAL","529 N MONROE AVE","","GREEN BAY","WI","543014909","BADGER SHEET METAL","529 N MONROE AVE","","GREEN BAY","WI","543014909","2422","10026242","Ingram Micro - 10026242",
"C124532","Volume HPN Switching Routing Applications Accessories NBO","","D721758","","","8/1/2013 12:00:00 AM","402561411","J9735A","2","","CAMERA CORNER CONNECTING POINT","BADGER SHEET METAL","GE COMMERCIAL DISTRIBUTION FIN CORP","DEALER #108250","WILLIAMSVILLE","NY","142210000","BADGER SHEET METAL","529 N MONROE AVE","","GREEN BAY","WI","543014909","BADGER SHEET METAL","529 N MONROE AVE","","GREEN BAY","WI","543014909","2422","10026242","Ingram Micro - 10026242",
"C124531","Volume PSG Notebooks NBO","","D647801","","","8/2/2013 12:00:00 AM","321737821","D8E66UT#ABA","11","","NETGAIN TECHNOLOGIES INC","CENTERS FOR YOUTH & FAMILIES","PO BOX 251970","","LITTLE ROCK","AR","722251970","CENTERS FOR YOUTH & FAMILIES","6501 W 12TH ST","","LITTLE ROCK",user@userPC:/mnt/9/$  & FAMILIES","6501 W 12TH ST","","LITTLE ROCK","AR","722041511","2422","10026242","Ingram Micro - 10026242",

It obviously consists of \r\n terminated liens.
# 11  
Old 08-27-2013
Quote:
Originally Posted by saga20
Thanks,its working & i am able to see the actual data but is there any way to see the actual data without resizing it to 64? Since that needs to be done manually,but i dont want to do it manually for every file.....
Why do it manually, that sounds very tedious and unpleasant? Write a quick shell script to reformat it automatically.
# 12  
Old 08-28-2013
Here is an awk-script that can do the job:
Code:
BEGIN {
    S = "";
}
{
    S = S $0;
    while (length(S) > 64)
    {
        print substr(S,1,64);
        S = substr(S,65);
    }
}
END {
    print S;
}

Usage:
Code:
awk -t script.awk <input >output

# 13  
Old 08-28-2013
Quote:
Originally Posted by hergp
Here is an awk-script that can do the job:
...provided that the file is not longer than the maximum line length. This limitation is true for this and all similar solutions (using sed, awk, fmt, etc.).

Wouldn't it be easier to use

Code:
fmt -64

instead?

I hope this helps.

bakunin
# 14  
Old 08-28-2013
Quote:
Originally Posted by bakunin
...provided that the file is not longer than the maximum line length.
If you look closely, you'll find, that the working string S will never be longer than the longest line of the input file plus 63. The script adds one line to S and then writes 64 character portions to the output file until S is shorter than 64 characters.

The easiest way would be to use the base64 utility from the GNU coreutils, because it does not care about the proper 64-character-linelength, but it is not available everywhere.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Encrypt and Decrypt a File with Password

Hello, I have few files on unix which are payroll related and I need them to encrypt with password so others wouldn't see the data. I use ETL tool and would like to know the unix command that does encryption/decryption to use in the ETL. Thank you, Sri (3 Replies)
Discussion started by: eskay
3 Replies

2. Programming

Encrypt and Decrypt file using RIJNDAEL-128

Hi All, Can I use MCRYPT - (RIJNDAEL-128) / CBC mode to encrypt and decrypt a file? I am trying to find some sample C program on internet, which will encrypt and decrypt a file. But was not able to find any thing. Can some help me with the programming. Thanks. (1 Reply)
Discussion started by: Shre
1 Replies

3. UNIX for Dummies Questions & Answers

How to Unmask/Decrypt an XML file?

Hello All, Below is the content of the XML datafile when i do vi the XML file not sure why the content is showing like this, it could be because the data inside the file is masked or something? is there a way i can decrypt or unmask the data in a human readable format? . When i use my Informatica... (20 Replies)
Discussion started by: Ariean
20 Replies

4. UNIX for Dummies Questions & Answers

How to decrypt any file in UNIX?

How to decrypt a file in unix? I dont know the type of decryption nor the type of text data it contains. We extracted the file from sfdc & need to process it in unix. When extracted, we get encrypted data in the file. The file content is- ... (0 Replies)
Discussion started by: saga20
0 Replies

5. Shell Programming and Scripting

Need to decrypt a file in a directory (SHL script)

I need to decrypt a file in a directory, I need to write a shl scrip & cron job How I find the files in the directory: the file is like this: dailypayments_sfs_payment_201011151800.dat -d The decrypt command: gpg -o dailypayments_sfs_payment_201011151800.dat -d 20101115 (the date... (7 Replies)
Discussion started by: rechever
7 Replies

6. Shell Programming and Scripting

decrypt the file

Hello all I am getting a encrypted file (.pgp) and a key which i have to use to decrypt that file. I couldn't understand where to put the key on my unix box so that decryption happens. Please reply. (2 Replies)
Discussion started by: vasuarjula
2 Replies

7. Shell Programming and Scripting

How to encrypt and decrypt a file

How to encrypt and decrypt a file using unix Command? Can any one help me? (2 Replies)
Discussion started by: laknar
2 Replies

8. Solaris

Decrypt Des file - then encrypt

Help.. I need to decrypt a file that was encrypted using DES 56 Bit. I have the encryption key and the block size used but no idea what utility to use.. I then need to encrypt the file using pgp and another key I have.. againt I dont know what utility to use. I am running solaris 9 .... ... (0 Replies)
Discussion started by: frustrated1
0 Replies

9. Programming

decrypt function in unix?

Hai Friends We have a function called char * crypt(const char *ps, const char* key) to encrypt the password in the unix environment.. Do we have any decrypt function to decrypt it? If not then how can we verify the password through program? Thanks in Advance Collins (1 Reply)
Discussion started by: collins
1 Replies

10. Shell Programming and Scripting

How to decrypt a file which is encrypted in UNIX, In Windows NT

Hi, I want to encrypt a file in UNIX(HP-UX) and Transfer to a FTP server. Our FTP server is Windows NT. SO, how can i decrypt the file which is encrypted in UNIX, in Windows NT. Please, help me this is urgent. Siva Gorantla:confused: (3 Replies)
Discussion started by: gorantla
3 Replies
Login or Register to Ask a Question