Results 1 to 3 of 3

Thread: Encryption from bash command line using perl module

  1. #1
    Join Date
    Jun 2008
    Location
    South-West France
    Posts
    1,069

    Default 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
    Code:
    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
    Code:
    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.
    Code:
    ~> 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.
    Code:
    ~> 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
    Thanks for helping. JCD
    __________
    server leap 15.0 -- ASUS g75vw KDE leap 15.0 -- ASUS g750JZ Optimus KDE leap 15.1 -- acer aspire s13 win 10 home -- HP Omen win 10 home - scan EPSON V500 - Brother HL2250DN - Samsung CLP-325W

  2. #2
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    11,447
    Blog Entries
    2

    Default Re: Encryption from bash command line using perl module

    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/forumdis...ming-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
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  3. #3
    Join Date
    Jun 2008
    Location
    South-West France
    Posts
    1,069

    Default [Solved] Encryption from bash command line using perl module

    Thanks for helping. JCD
    __________
    server leap 15.0 -- ASUS g75vw KDE leap 15.0 -- ASUS g750JZ Optimus KDE leap 15.1 -- acer aspire s13 win 10 home -- HP Omen win 10 home - scan EPSON V500 - Brother HL2250DN - Samsung CLP-325W

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •