You are starting with a variable that contains a JavaScript literal minus the quotes (e.g. "\","3","4",0"), and you want code to generate the string JavaScript would produce by that literal (byte E016).

This has nothing to do with UTF-8 or Unicode. The byte may be part of the UTF-8 encoding of some string, but md5_hex doesn't care about that.

my $chapid3= '\027'; my $chapchalange3= '\340\174\012\314\214\070\070\231\377\005\016\132\2 +70\024\241\163'; s/\\(\d{3})/chr(oct($1))/eg for $chapid3, $chapchalange3; print "\nExample2=".Digest::MD5::md5_hex($chapid3."AAA".$chapchalange3 +);

And I see no utf8 flag for the internal representation?

That flag should never matter. It only does in the presence of bugs. md5_hex is not buggy.

perl -MTest::More=tests,1 -MDigest::MD5=md5_hex -e' $_ = chr(0xE9); utf8::downgrade( $dn = $_ ); utf8::upgrade( $up = $_ ); is(md5_hex($up), md5_hex($dn)); ' 1..1 ok 1

If anything, I would suspect a problem if the flag was on.


In reply to Re: Perl CGI UTF8 AND CHAP PASSWORD VERIFICATION by ikegami
in thread Perl CGI UTF8 AND CHAP PASSWORD VERIFICATION by kaloyan_iliev

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.