Sponsored Content
Top Forums UNIX for Dummies Questions & Answers perl pack and unpack commands Post 302491785 by erinlomo on Friday 28th of January 2011 09:13:50 AM
Old 01-28-2011
perl pack and unpack commands

I am using pack/unpack to encyrpt a file.
syntax is below
Code:
#!/bin/sh
encrypt=`perl -e 'print unpack "H*","yourpassword"'`    -
echo $encrypt >/file/to/store/encrypted/password        

pass=`cat /file/to/store/encrypted/password`           
decrypt=`perl -e 'print pack "H*",$pass'`

The problem is decrypt returns a null value, whereas if i put the value instead of variable like below
Code:
decrypt=`perl -e 'print pack "H*","16283562f736"'`

it works ok.
any suggestions please?

Thanks all

Moderator's Comments:
Mod Comment Please use code tags for listings, console output, ...

Last edited by pludi; 01-28-2011 at 10:46 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl + pack() + spaceing question

ok guys and gals at the moment i am perplexed (prolly cuz i been looking at it to long) but here it is. OS: sol8 perlver: 5.8.0 shell: ksh answer must be in perl!! issue: when i use pack() it packs the data at the front of the requested field space. normally it wouldnt be a problem if... (1 Reply)
Discussion started by: Optimus_P
1 Replies

2. UNIX for Dummies Questions & Answers

does any body know how to unpack this file?????

this file i'm trying to unpack is a cloop file (1 Reply)
Discussion started by: amicrawler2000
1 Replies

3. Shell Programming and Scripting

Perl help!! (pack()?)

Hello everyone. I wrote a perl script to get the two answers from a value: x. By this, I want to do sqrt($x) in different precision. #!/usr/bin/perl print "Input the initial value x:\n"; chomp($x=<STDIN>); $comp=sqrt($x); $float_value=pack("f", $comp); $double_value=pack("d", $comp);... (2 Replies)
Discussion started by: Euler04
2 Replies

4. UNIX for Dummies Questions & Answers

simple unpack script

hi all.... I'm a newbie to Shell scripting and am trying to make a simple script that can unpack a variety of .tgz , .zip, .tar or .tar.gz archives to the a current directory i want the script to create a folder equivalent to the base name of the archive and then move the archive to a... (18 Replies)
Discussion started by: jboss
18 Replies

5. Shell Programming and Scripting

[PERL] Running unix commands within Perl Scripts

I understand that in order to run basic unix commands I would normally type at the prompt, I would have to use the following format system(ls -l); or exec(ls -l); But when I actually try to use the command, the script fails to compile and keeps telling me there is an error with this line. ... (1 Reply)
Discussion started by: userix
1 Replies

6. UNIX for Dummies Questions & Answers

perl pack and unpack commands

I have a file that contains user id and corresponding password. Lets say password is "help". The below command will create a hex value for string "help". perl -e 'print unpack "H*","help"' So now password is in encoded format. Then I decoded it in the script where am fetching the... (1 Reply)
Discussion started by: max_payne1234
1 Replies

7. Shell Programming and Scripting

Bash equivalent of perl's pack function ?

Is there an equivalent of perl's pack function in bash ? Or in other words, how can I achieve the same thing in bash ? Much appreciated. (1 Reply)
Discussion started by: NewDeb
1 Replies

8. UNIX for Advanced & Expert Users

Perl-to-Oracle performance: DBI-pack visa 'sqlplus' usage

I wondering if anybody tried already or know about the performance to process some Oracle staff from Perl. I see it could be done by the DBI pachage (so, I guess, it is interface to the OCI, but who know how sufficiant it is..,) with all gemicks around (define, open, parce, bind,.. ), or it can... (8 Replies)
Discussion started by: alex_5161
8 Replies

9. Shell Programming and Scripting

Pack and unpack localtime in perl script

Hi I have a code like this: sub WriteEbcdicHeader { my $Htimestamp=localtime();#i need to pack and unpack this my $eheaderline = $Htimestamp; #packing has to be done here #unpacking has to be done after packing print $EOUTFILE return $eheaderline; } sub WriteEbcdicTrailer { ... (5 Replies)
Discussion started by: rbathena
5 Replies

10. Shell Programming and Scripting

what is the difference between commands compress, pack and gzip

Are the above commands does the same job ? same functionaliy ? If so, why do we have three utilities for the same functinality. (1 Reply)
Discussion started by: frintocf
1 Replies
MooseX::Storage::Basic(3pm)				User Contributed Perl Documentation			       MooseX::Storage::Basic(3pm)

NAME
MooseX::Storage::Basic - The simplest level of serialization VERSION
version 0.45 SYNOPSIS
package Point; use Moose; use MooseX::Storage; with Storage; has 'x' => (is => 'rw', isa => 'Int'); has 'y' => (is => 'rw', isa => 'Int'); 1; my $p = Point->new(x => 10, y => 10); ## methods to pack/unpack an ## object in perl data structures # pack the class into a hash $p->pack(); # { __CLASS__ => 'Point-0.01', x => 10, y => 10 } # unpack the hash into a class my $p2 = Point->unpack({ __CLASS__ => 'Point-0.01', x => 10, y => 10 }); # unpack the hash, with insertion of paramaters my $p3 = Point->unpack( $p->pack, inject => { x => 11 } ); DESCRIPTION
This is the most basic form of serialization. This is used by default but the exported "Storage" function. METHODS
pack ([ disable_cycle_check = 1])> Providing the "disable_cycle_check" argument disables checks for any cyclical references. The current implementation for this check is rather naive, so if you know what you are doing, you can bypass this check. This trait is applied on a perl-case basis. To set this flag for all objects that inherit from this role, see MooseX::Storage::Traits::DisableCycleDetection. unpack ($data [, insert = { key => val, ... } ] )> Providing the "insert" argument let's you supply additional arguments to the class' "new" function, or override ones from the serialized data. Introspection meta BUGS
All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. AUTHORS
o Chris Prather <chris.prather@iinteractive.com> o Stevan Little <stevan.little@iinteractive.com> o XXXX XXX'XX (Yuval Kogman) <nothingmuch@woobling.org> COPYRIGHT AND LICENSE
This software is copyright (c) 2007 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.18.2 2013-12-21 MooseX::Storage::Basic(3pm)
All times are GMT -4. The time now is 09:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy