Encryption from bash command line using perl module

Hello.

Question 1

/usr/lib/perl5 contains 3 different perl installations :/usr/lib/perl5/5.18.2
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl

When calling a perl module/function which version is in use ?

Question 2

I use this command

perl -MMIME::Base64 -e 'print encode_base64("some_user");'

to get a base64 encoded user name or user password.

I would like to use this command

perl -MXXXXXX::YYYYYY -e 'print ZZZZZZZ("some_user");'

to get a md5 encoded user name or user password.
I have tried different command flavor with no success.

~> perl -MDigest::MD5 -e 'print encode_base64("some_user");'
Undefined subroutine &main::encode_base64 called at -e line 1.

~> perl -MDigest::MD5 -e 'print md5_base64("some_user");'
Undefined subroutine &main::md5_base64 called at -e line 1.

~> perl -MDigest::MD5 -e 'print hmac_md5("some_user");'
Undefined subroutine &main::hmac_md5 called at -e line 1.

~> perl -MDigest::HMAC_MD5 -e 'print hmac_md5("some_user");'
Undefined subroutine &main::hmac_md5 called at -e line 1.

~> perl -MDigest::MD5 -e 'print md5_base64("some_user");'
Undefined subroutine &main::md5_base64 called at -e line 1.

~> perl -MDigest::MD5 -e 'print hmac_md5("some_user");'
Undefined subroutine &main::hmac_md5 called at -e line 1.

~> perl -MDigest::MD5 -e 'print md5("some_user");'
Undefined subroutine &main::md5 called at -e line 1.
~> perl -e 'use HMAC_MD5;'
Can't locate HMAC_MD5.pm in @INC (you may need to install the HMAC_MD5 module) (@INC contains: /usr/lib/perl5/site_perl/5.18.2/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.18.2 /usr/lib/perl5/vendor_perl/5.18.2/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.18.2 /usr/lib/perl5/5.18.2/x86_64-linux-thread-multi /usr/lib/perl5/5.18.2 /usr/lib/perl5/site_perl .) at -e line 1.
BEGIN failed--compilation aborted at -e line 1.

~> perl -e 'use MD5;'
Can't locate MD5.pm in @INC (you may need to install the MD5 module) (@INC contains: /usr/lib/perl5/site_perl/5.18.2/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.18.2 /usr/lib/perl5/vendor_perl/5.18.2/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.18.2 /usr/lib/perl5/5.18.2/x86_64-linux-thread-multi /usr/lib/perl5/5.18.2 /usr/lib/perl5/site_perl .) at -e line 1.
BEGIN failed--compilation aborted at -e line 1. 

But HMAC_MD5.pm is in “/usr/lib/perl5/vendor_perl/5.18.2/Digest”
and MD5.pm is in “/usr/lib/perl5/vendor_perl/5.18.2/x86_64-linux-thread-multi/Digest” or in “/usr/lib/perl5/5.18.2/x86_64-linux-thread-multi/Digest”

Any help is welcome

First,
I’m sure if you post a question about script coding in the Development forums, you’ll get better responses…

https://forums.opensuse.org/forumdisplay.php/678-Programming-Scripting

I have never coded any particular amount in Perl, so can’t answer your questions properly,
But your second question suggests that you should write your code a modular way, first encoding your strings using native commands and storing them in variables, then running your Perl script referencing those variables.

That way you can avoid running Perl modules for your encrypting/decrypting.

As for your first question… I suppose to be sure what version of Perl you’re running, you could insert an echo statement returning the Perl version somewhere in your script.

BTW - I guess you know that BASE64 is considered next to totally ineffective as an encryption algorithm… It was broken and considered trivial to decrypt ban in the 16-bit days? It’s something to keep honest people honest, or maybe used strictly for educational purposes but should never be used to secure anything.

HTH,
TSU

Question have answers here
http://forums.opensuse.org/showthread.php/534404-perl-What-version-is-in-use

see :
http://forums.opensuse.org/showthread.php/534404-perl-What-version-is-in-use

This thread is closed