perl - MIME::Base64::decode_base64 wrong characters -


i troubles using perl mime::base64::decode_base64

here code:

#!/usr/bin/perl use mime::base64; $string_to_decrypt="lvvfrx23jx7vx3hghyjgxo4oivqbig"; $content=mime::base64::decode_base64($string_to_decrypt); open(write,">/home/laurent/decrypted.txt"); print write $content; close(write); exit; 

using online decoder (like https://www.base64decode.org/) result should be:

[߯·~ï_qà"fÆ(ú" 

but in file, get:

<95>[߯^]·<8d>~ï_qà<87>"fÆ<8e>(<8a>ú<81>" 

i don't know how rid of:

 <95>, ^], <8d>,<87> .... 

thanks laurent

this not text, it's no surprise doesn't render when printed text. base64decode.org produces same correct result decode_base64, following bytes:

95.5b.df.af.1d.b7.8d.7e.ef.5f.71.e0.87.22.46.c6.8e.28.8a.fa.81.22 

you can use either of following remove characters identified, that's wrong thing do.

$content =~ tr/\x1d\x87\x8d\x95//d;   -or- $content =~ s/[\x1d\x87\x8d\x95]//g; 

Comments