develooper Front page | perl.beginners | Postings from December 2005

Re: encode base64 password

Thread Previous
Adriano Ferreira
December 22, 2005 03:27
Re: encode base64 password
Message ID:
On 12/22/05, Ken Perl <> wrote:
> Is the MIME::Base64 support unicode?

MIME::Base64 supports conversion of binary data into a limited character set,
convenient for transmission by e-mail and other means that prefer pure ASCII

> I am trying to use the module to encode the  a password.

Passwords protected by such a straightforward encoding/decoding are
not protected. If you have serious concerns about security, try
something like the Digest::* modules (available at CPAN).

> In the doc;en-us;263991
> there is one line like this unicodePwd::IgBuAGUAdwBQAGEAcwBzAHcAbwByAGQAIgA=
> the encoded string is what I want to produce using the module, I tried this,

The point is:
(1) first they took the string "newPassword" (including the quotes)

     $s = q{"newPassword"};

(2) converted it to bytes via utf-16le (take a look at "perldoc perlunicode")

     use Encode;
     $octets = encode("utf-16le", $s);

(3) and then applied base64 encoding

     $encoded = encode_base64($octets);

(4) which resulted in

     print $encoded;


So the code you want is


use MIME::Base64;
use Encode;

$s = q{welcome};
$octets = encode("utf-16le", $s);
$encoded = encode_base64($octets);
print $encoded;

below is the output,

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About