Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Saving an unencrypted copy of a file encrypted with vi Post 302897558 by Perderabo on Monday 14th of April 2014 07:06:06 PM
Old 04-14-2014
The last time I did this was in the 80's. and my memory is a bit hazy...

I think you need the crypt command. Write the file out, it will be encrypted and let's call the output ciphertext. Then run:
Code:
crypt < ciphertext > plaintext

I don't remember if crypt will prompt you for the key or if you pass it as a parameter. Give that a try and please let us know if it works.
 

10 More Discussions You Might Find Interesting

1. 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

2. UNIX for Advanced & Expert Users

netrc file encrypted password

Hi, I do not want the plaintext password to appear in the netrc file. So I want to encrypt the password. Is there a way to encrypt the password and still make ftp to use the netrc ? Thanks in advance. -Gow:confused: (2 Replies)
Discussion started by: ggowrish
2 Replies

3. Shell Programming and Scripting

Retain file permissions when saving .sh file from internet [OS X]

Hello. I have written a bash script that I am sharing with an OS X community I am a member of. The purpose of the script is to execute a series of commands for members without them having to get involved with Terminal, as it can be daunting for those with no experience of it at all. I have renamed... (4 Replies)
Discussion started by: baza210
4 Replies

4. UNIX for Dummies Questions & Answers

how to run an ENCRYPTED file?

Hello sir, we are able to do : But when I goto /bin or /usr/bin to see the code of "ls". I found it to be encrypted. So can u please tell me how to encrypt a code in such a way that the user can run it but cannot see the source code. example: if I have a shell script named "sample.sh" as... (5 Replies)
Discussion started by: nsharath
5 Replies

5. Shell Programming and Scripting

FTP file from MF to AIX, fully encrypted

Hi All, I have connected to MainFrame system from Unix AIX Server then using ftp i get the file "NJUSP_XYXYXY_NONONO" to Unix. Now when i tried opening this file using cat/more i am getting the content fully in encrypted format. please help me to read the content of this file from my Unix... (5 Replies)
Discussion started by: Arunprasad
5 Replies

6. Solaris

How edit a file encrypted with openssl ?

i have file encrypted with openssl and i can decrypt and view its content by below code openssl enc -d -blowfish -pass file:secret_key -in input_file now i need to edit the input_file . i have to remove three lines from this file . how can this be done ? (3 Replies)
Discussion started by: chidori
3 Replies

7. Programming

[Solved] Removing duplicates from the file and saving as new file

Dear All I have 200 data files and each files has many duplicates. I am looking for the automated awk script such that it checks and removes the duplicates from the each file and saving them as new files for all 200 files in the respective folder. For example my data looks like this.. ... (12 Replies)
Discussion started by: bala06
12 Replies

8. UNIX for Dummies Questions & Answers

Using the encrypted password of the shadow file

i have an application that uses the encrypted password that's in the /etc/shadow file. i copied the line for the particular username i was interested it in from shadow file and i pasted it into the password file of the application. the application is nagios. this application allowed that... (5 Replies)
Discussion started by: SkySmart
5 Replies

9. UNIX for Advanced & Expert Users

How To Find GPG Keys In Encrypted File With Out Decrypting it?

Hello All, Is there a way to determine how many public keys are embedded or used to encrypt in a GPG file with out decrypting the actual encrypted file. I know i can see the keys & email id's used when we decrypt it, but curious to find a command if any to know with out decrypting the actual file... (2 Replies)
Discussion started by: Ariean
2 Replies

10. Shell Programming and Scripting

Find the original file size of encrypted file

Hi, I am trying to find out the original file size of an encrypted file in SunOS. The file was decrypted with gpg command. I want to know the size of the orginal file without decrypting it. I am using the below command, but it is not working for big files(more than 1 GB). gpg --passphrase... (4 Replies)
Discussion started by: vsachan
4 Replies
ECB(3pm)						User Contributed Perl Documentation						  ECB(3pm)

NAME
Crypt::ECB - Encrypt Data using ECB Mode SYNOPSIS
Use Crypt::ECB OO style use Crypt::ECB; $crypt = Crypt::ECB->new; $crypt->padding(PADDING_AUTO); $crypt->cipher('Blowfish') || die $crypt->errstring; $crypt->key('some_key'); $enc = $crypt->encrypt("Some data."); print $crypt->decrypt($enc); or use the function style interface use Crypt::ECB qw(encrypt decrypt encrypt_hex decrypt_hex); $ciphertext = encrypt($key, 'Blowfish', "Some data", PADDING_AUTO); $plaintext = decrypt($key, 'Blowfish', $ciphertext, PADDING_AUTO); $hexcode = encrypt_hex($key, $cipher, $plaintext); $plain = decrypt_hex($key, $cipher, $hexcode); DESCRIPTION
This module is a Perl-only implementation of the ECB mode. In combination with a block cipher such as DES, IDEA or Blowfish, you can encrypt and decrypt messages of arbitrarily long length. Though for security reasons other modes than ECB such as CBC should be preferred. See textbooks on cryptography if you want to know why. The functionality of the module can be accessed via OO methods or via standard function calls. Remember that some crypting module like for example Blowfish has to be installed. The syntax follows that of Crypt::CBC. METHODS
new(), key(), cipher(), padding() $crypt = Crypt::ECB->new; $crypt->key('Some_key'); $crypt->cipher('Blowfish') || die $crypt->errstring; $crypt->padding(PADDING_AUTO); print $crypt->key; print $crypt->cipher; print $crypt->padding; $crypt = Crypt::ECB->new('Some_key','Blowfish'); $crypt->cipher || die "'Blowfish' wasn't loaded for some reason."; new() initializes the variables it uses. Optional parameters are key and cipher. If called without parameters you have to call key() and cipher() before you can start crypting. If called with key but without cipher, for compatibility with Crypt::CBC 'DES' is assumed. key() sets the key if given a parameter. It always returns the key. Note that some crypting modules require keys of definite length. For example the Crypt::Blowfish module expects an eight byte key. cipher() sets the block cipher to be used if given a parameter. It tries to load the corresponding module. If an error occurs, it returns 0 and sets $crypt->{Errstring}. Otherwise it returns the cipher name. Free packages available for Perl are for example Blowfish, DES or IDEA. If called without parameter it just returns the name of the cipher. padding() sets the way how data is padded up to a multiple of the cipher's blocksize. Until now two ways are implemented: When set to PAD- DING_NONE, no padding is done. You then have to take care of correct padding (and truncating) yourself. When set to PADDING_AUTO, the ECB module handles padding (and truncating when decrypting) the same way Crypt::CBC does. By default the padding style is set to PADDING_NONE. This means if you don't bother and your data has not the correct length, the module will complain and therefore force you to think about what you really want. start(), mode(), crypt(), finish() $crypt->start('encrypt') || die $crypt->errstring; $enc .= $crypt->crypt($_) foreach (@lines); $enc .= $crypt->finish; $crypt->start('decrypt'); print $crypt->mode; start() sets the crypting mode and checks if all required variables like key and cipher are set. Allowed parameters are any words starting either with 'e' or 'd'. The Method returns the mode which is set or 0 if an error occurred. mode() is called without parameters and just returns the mode which is set. crypt() processes the data given as argument. If called without argument $_ is processed. The method returns the processed data. Cipher and key have to be set in order to be able to process data. If some of these are missing or start() was not called before, the method dies. After having sent all data to be processed to crypt() you have to call finish() in order to flush data that's left in the buffer. caching() $crypt->caching(1); # caching on $crypt->caching(0); # caching off print $crypt->caching; The caching mode is returned. If given an argument caching mode is set. Caching is on if caching() evaluates true, otherwise caching is off. By default caching is on. What is this caching? The Crypt::ECB module communicates with the cipher module via some object. Creating the cipher object takes some time for the cipher module has to do some initialization. Now caching means that the same cipher object is used until caching is turned off or the key or the cipher module are changed. If caching is off, a new cipher object is created is created each time crypt() or finish() are called and destroyed at the end of these methods. Crypting using caching is much faster than without caching. encrypt(), decrypt(), encrypt_hex(), decrypt_hex() $enc = $crypt->encrypt($data); print $crypt->decrypt($enc); $hexenc = $crypt->encrypt_hex($data); print $crypt->decrypt_hex($hexenc); encrypt() and decrypt() are convenience methods which call start(), crypt() and finish() for you. encrypt_hex() and decrypt_hex() are convenience functions that operate on ciphertext in a hexadecimal representation. They are exactly equivalent to $hexenc = join('',unpack('H*',$crypt->encrypt($data))); print $crypt->decrypt(pack('H*',$hexenc)); These functions can be useful if, for example, you wish to place the encrypted information into an e-mail message, Web page or URL. errstring() print $crypt->errstring; Some methods like cipher() or start() return 0 if an error occurs. You can then retrieve a more detailed error message by calling $crypt->errstring. VARIABLES
Variables which could be of interest to the outside world are: $crypt->{Key}, $crypt->{Cipher}, $crypt->{Module}, $crypt->{Keysize}, $crypt->{Blocksize}, $crypt->{Mode}, $crypt->{Caching}, $crypt->{Padding}, $crypt->{Errstring}. The variables should not be set directly, use instead the above described methods. Reading should not pose a problem. CONSTANTS
The two constants naming the padding styles are exported by default: PADDING_NONE => 0 PADDING_AUTO => 1 FUNCTIONS
For convenience en- or decrypting can also be done by calling ordinary functions. The functions are: encrypt(), decrypt(), encrypt_hex, decrypt_hex. The module is smart enough to recognize whether these functions are called in an OO context or not. encrypt(), decrypt(), encrypt_hex(), decrypt_hex() $ciphertext = encrypt($key, $cipher, $plaintext, PADDING_AUTO); $plaintext = decrypt($key, $cipher, $ciphertext, PADDING_AUTO); $ciphertext = encrypt_hex($key, $cipher, $plaintext, PADDING_AUTO); $plaintext = decrypt_hex($key, $cipher, $ciphertext, PADDING_AUTO); encrypt() and decrypt() process the provided text and return either the corresponding ciphertext (encrypt) or plaintext (decrypt). Data and padstyle are optional, but remember that by default no padding is done. If data is omitted, $_ is assumed. encrypt_hex() and decrypt_hex() operate on ciphertext in a hexadecimal representation. Otherwise usage is the same as for encrypt() and decrypt(). BUGS
None that I know of. TODO
The other block cipher modes CBC, CFB and OFB could be implemented. Convenience encrypt and decrypt functions utilizing base64 encoding could be added. COPYING
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. AUTHOR
Christoph Appel (see ECB.pm for email address) SEE ALSO
perl(1), Crypt::DES(3), Crypt::IDEA(3), Crypt::CBC(3) perl v5.8.8 2005-01-07 ECB(3pm)
All times are GMT -4. The time now is 01:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy