On 12/22/05, Ken Perl <[EMAIL PROTECTED]> 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
data.

> 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 http://support.microsoft.com/default.aspx?scid=kb;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;

     > IgBuAGUAdwBQAGEAcwBzAHcAbwByAGQAIgA=

So the code you want is

#!/usr/bin/perl

use MIME::Base64;
use Encode;

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

__END__
below is the output,
dwBlAGwAYwBvAG0AZQA=

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to