{
    "content": [
        {
            "type": "text",
            "text": "# Digest::MD5 (info)\n\n## NAME\n\nDigest::MD5 - Perl interface to the MD5 Algorithm\n\n## SYNOPSIS\n\n# Functional style\nuse Digest::MD5 qw(md5 md5hex md5base64);\n$digest = md5($data);\n$digest = md5hex($data);\n$digest = md5base64($data);\n# OO style\nuse Digest::MD5;\n$ctx = Digest::MD5->new;\n$ctx->add($data);\n$ctx->addfile($filehandle);\n$digest = $ctx->digest;\n$digest = $ctx->hexdigest;\n$digest = $ctx->b64digest;\n\n## DESCRIPTION\n\nThe \"Digest::MD5\" module allows you to use the RSA Data Security Inc.\nMD5 Message Digest algorithm from within Perl programs.  The algorithm\ntakes as input a message of arbitrary length and produces as output a\n128-bit \"fingerprint\" or \"message digest\" of the input.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **FUNCTIONS**\n- **METHODS**\n- **EXAMPLES**\n- **SEE ALSO**\n- **COPYRIGHT**\n- **AUTHORS**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Digest::MD5",
        "section": "",
        "mode": "info",
        "summary": "Digest::MD5 - Perl interface to the MD5 Algorithm",
        "synopsis": "# Functional style\nuse Digest::MD5 qw(md5 md5hex md5base64);\n$digest = md5($data);\n$digest = md5hex($data);\n$digest = md5base64($data);\n# OO style\nuse Digest::MD5;\n$ctx = Digest::MD5->new;\n$ctx->add($data);\n$ctx->addfile($filehandle);\n$digest = $ctx->digest;\n$digest = $ctx->hexdigest;\n$digest = $ctx->b64digest;",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [
            "The simplest way to use this library is to import the md5hex()",
            "function (or one of its cousins):",
            "use Digest::MD5 qw(md5hex);",
            "print \"Digest is \", md5hex(\"foobarbaz\"), \"\\n\";",
            "The above example would print out the message:",
            "Digest is 6df23dc03f9b54cc38a0fc1483df6e21",
            "The same checksum can also be calculated in OO style:",
            "use Digest::MD5;",
            "$md5 = Digest::MD5->new;",
            "$md5->add('foo', 'bar');",
            "$md5->add('baz');",
            "$digest = $md5->hexdigest;",
            "print \"Digest is $digest\\n\";",
            "With OO style, you can break the message arbitrarily.  This means that",
            "we are no longer limited to have space for the whole message in memory,",
            "i.e.  we can handle messages of any size.",
            "This is useful when calculating checksum for files:",
            "use Digest::MD5;",
            "my $filename = shift || \"/etc/passwd\";",
            "open (my $fh, '<', $filename) or die \"Can't open '$filename': $!\";",
            "binmode($fh);",
            "$md5 = Digest::MD5->new;",
            "while (<$fh>) {",
            "$md5->add($);",
            "close($fh);",
            "print $md5->b64digest, \" $filename\\n\";",
            "Or we can use the addfile method for more efficient reading of the",
            "file:",
            "use Digest::MD5;",
            "my $filename = shift || \"/etc/passwd\";",
            "open (my $fh, '<', $filename) or die \"Can't open '$filename': $!\";",
            "binmode ($fh);",
            "print Digest::MD5->new->addfile($fh)->hexdigest, \" $filename\\n\";",
            "Since the MD5 algorithm is only defined for strings of bytes, it can",
            "not be used on strings that contains chars with ordinal number above",
            "255 (Unicode strings).  The MD5 functions and methods will croak if you",
            "try to feed them such input data:",
            "use Digest::MD5 qw(md5hex);",
            "my $str = \"abc\\x{300}\";",
            "print md5hex($str), \"\\n\";  # croaks",
            "# Wide character in subroutine entry",
            "What you can do is calculate the MD5 checksum of the UTF-8",
            "representation of such strings.  This is achieved by filtering the",
            "string through encodeutf8() function:",
            "use Digest::MD5 qw(md5hex);",
            "use Encode qw(encodeutf8);",
            "my $str = \"abc\\x{300}\";",
            "print md5hex(encodeutf8($str)), \"\\n\";",
            "# 8c2d46911f3f5a326455f0ed7a8ed3b3"
        ],
        "see_also": [
            {
                "name": "md5sum",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/md5sum/1/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 19,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 16,
                "subsections": []
            },
            {
                "name": "FUNCTIONS",
                "lines": 27,
                "subsections": []
            },
            {
                "name": "METHODS",
                "lines": 100,
                "subsections": []
            },
            {
                "name": "EXAMPLES",
                "lines": 73,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 11,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 36,
                "subsections": []
            },
            {
                "name": "AUTHORS",
                "lines": 7,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Digest::MD5 - Perl interface to the MD5 Algorithm\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "# Functional style\nuse Digest::MD5 qw(md5 md5hex md5base64);\n\n$digest = md5($data);\n$digest = md5hex($data);\n$digest = md5base64($data);\n\n# OO style\nuse Digest::MD5;\n\n$ctx = Digest::MD5->new;\n\n$ctx->add($data);\n$ctx->addfile($filehandle);\n\n$digest = $ctx->digest;\n$digest = $ctx->hexdigest;\n$digest = $ctx->b64digest;\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "The \"Digest::MD5\" module allows you to use the RSA Data Security Inc.\nMD5 Message Digest algorithm from within Perl programs.  The algorithm\ntakes as input a message of arbitrary length and produces as output a\n128-bit \"fingerprint\" or \"message digest\" of the input.\n\nNote that the MD5 algorithm is not as strong as it used to be.  It has\nsince 2005 been easy to generate different messages that produce the\nsame MD5 digest.  It still seems hard to generate messages that produce\na given digest, but it is probably wise to move to stronger algorithms\nfor applications that depend on the digest to uniquely identify a\nmessage.\n\nThe \"Digest::MD5\" module provide a procedural interface for simple use,\nas well as an object oriented interface that can handle messages of\narbitrary length and which can read files directly.\n",
                "subsections": []
            },
            "FUNCTIONS": {
                "content": "The following functions are provided by the \"Digest::MD5\" module.  None\nof these functions are exported by default.\n\nmd5($data,...)\nThis function will concatenate all arguments, calculate the MD5\ndigest of this \"message\", and return it in binary form.  The\nreturned string will be 16 bytes long.\n\nThe result of md5(\"a\", \"b\", \"c\") will be exactly the same as the\nresult of md5(\"abc\").\n\nmd5hex($data,...)\nSame as md5(), but will return the digest in hexadecimal form. The\nlength of the returned string will be 32 and it will only contain\ncharacters from this set: '0'..'9' and 'a'..'f'.\n\nmd5base64($data,...)\nSame as md5(), but will return the digest as a base64 encoded\nstring.  The length of the returned string will be 22 and it will\nonly contain characters from this set: 'A'..'Z', 'a'..'z',\n'0'..'9', '+' and '/'.\n\nNote that the base64 encoded string returned is not padded to be a\nmultiple of 4 bytes long.  If you want interoperability with other\nbase64 encoded md5 digests you might want to append the redundant\nstring \"==\" to the result.\n",
                "subsections": []
            },
            "METHODS": {
                "content": "The object oriented interface to \"Digest::MD5\" is described in this\nsection.  After a \"Digest::MD5\" object has been created, you will add\ndata to it and finally ask for the digest in a suitable format.  A\nsingle object can be used to calculate multiple digests.\n\nThe following methods are provided:\n\n$md5 = Digest::MD5->new\nThe constructor returns a new \"Digest::MD5\" object which\nencapsulate the state of the MD5 message-digest algorithm.\n\nIf called as an instance method (i.e. $md5->new) it will just reset\nthe state the object to the state of a newly created object.  No\nnew object is created in this case.\n\n$md5->reset\nThis is just an alias for $md5->new.\n\n$md5->clone\nThis a copy of the $md5 object. It is useful when you do not want\nto destroy the digests state, but need an intermediate value of the\ndigest, e.g. when calculating digests iteratively on a continuous\ndata stream.  Example:\n\nmy $md5 = Digest::MD5->new;\nwhile (<>) {\n$md5->add($);\nprint \"Line $.: \", $md5->clone->hexdigest, \"\\n\";\n}\n\n$md5->add($data,...)\nThe $data provided as argument are appended to the message we\ncalculate the digest for.  The return value is the $md5 object\nitself.\n\nAll these lines will have the same effect on the state of the $md5\nobject:\n\n$md5->add(\"a\"); $md5->add(\"b\"); $md5->add(\"c\");\n$md5->add(\"a\")->add(\"b\")->add(\"c\");\n$md5->add(\"a\", \"b\", \"c\");\n$md5->add(\"abc\");\n\n$md5->addfile($iohandle)\nThe $iohandle will be read until EOF and its content appended to\nthe message we calculate the digest for.  The return value is the\n$md5 object itself.\n\nThe addfile() method will croak() if it fails reading data for some\nreason.  If it croaks it is unpredictable what the state of the\n$md5 object will be in. The addfile() method might have been able\nto read the file partially before it failed.  It is probably wise\nto discard or reset the $md5 object if this occurs.\n\nIn most cases you want to make sure that the $iohandle is in\n\"binmode\" before you pass it as argument to the addfile() method.\n\n$md5->addbits($data, $nbits)\n$md5->addbits($bitstring)\nSince the MD5 algorithm is byte oriented you might only add bits as\nmultiples of 8, so you probably want to just use add() instead.\nThe addbits() method is provided for compatibility with other\ndigest implementations.  See Digest for description of the\narguments that addbits() take.\n\n$md5->digest\nReturn the binary digest for the message.  The returned string will\nbe 16 bytes long.\n\nNote that the \"digest\" operation is effectively a destructive,\nread-once operation. Once it has been performed, the \"Digest::MD5\"\nobject is automatically \"reset\" and can be used to calculate\nanother digest value.  Call $md5->clone->digest if you want to\ncalculate the digest without resetting the digest state.\n\n$md5->hexdigest\nSame as $md5->digest, but will return the digest in hexadecimal\nform. The length of the returned string will be 32 and it will only\ncontain characters from this set: '0'..'9' and 'a'..'f'.\n\n$md5->b64digest\nSame as $md5->digest, but will return the digest as a base64\nencoded string.  The length of the returned string will be 22 and\nit will only contain characters from this set: 'A'..'Z', 'a'..'z',\n'0'..'9', '+' and '/'.\n\nThe base64 encoded string returned is not padded to be a multiple\nof 4 bytes long.  If you want interoperability with other base64\nencoded md5 digests you might want to append the string \"==\" to the\nresult.\n\n@ctx = $md5->context\n$md5->context(@ctx)\nSaves or restores the internal state.  When called with no\narguments, returns a list: number of blocks processed, a 16-byte\ninternal state buffer, then optionally up to 63 bytes of\nunprocessed data if there are any.  When passed those same\narguments, restores the state.  This is only useful for specialised\noperations.\n",
                "subsections": []
            },
            "EXAMPLES": {
                "content": "The simplest way to use this library is to import the md5hex()\nfunction (or one of its cousins):\n\nuse Digest::MD5 qw(md5hex);\nprint \"Digest is \", md5hex(\"foobarbaz\"), \"\\n\";\n\nThe above example would print out the message:\n\nDigest is 6df23dc03f9b54cc38a0fc1483df6e21\n\nThe same checksum can also be calculated in OO style:\n\nuse Digest::MD5;\n\n$md5 = Digest::MD5->new;\n$md5->add('foo', 'bar');\n$md5->add('baz');\n$digest = $md5->hexdigest;\n\nprint \"Digest is $digest\\n\";\n\nWith OO style, you can break the message arbitrarily.  This means that\nwe are no longer limited to have space for the whole message in memory,\ni.e.  we can handle messages of any size.\n\nThis is useful when calculating checksum for files:\n\nuse Digest::MD5;\n\nmy $filename = shift || \"/etc/passwd\";\nopen (my $fh, '<', $filename) or die \"Can't open '$filename': $!\";\nbinmode($fh);\n\n$md5 = Digest::MD5->new;\nwhile (<$fh>) {\n$md5->add($);\n}\nclose($fh);\nprint $md5->b64digest, \" $filename\\n\";\n\nOr we can use the addfile method for more efficient reading of the\nfile:\n\nuse Digest::MD5;\n\nmy $filename = shift || \"/etc/passwd\";\nopen (my $fh, '<', $filename) or die \"Can't open '$filename': $!\";\nbinmode ($fh);\n\nprint Digest::MD5->new->addfile($fh)->hexdigest, \" $filename\\n\";\n\nSince the MD5 algorithm is only defined for strings of bytes, it can\nnot be used on strings that contains chars with ordinal number above\n255 (Unicode strings).  The MD5 functions and methods will croak if you\ntry to feed them such input data:\n\nuse Digest::MD5 qw(md5hex);\n\nmy $str = \"abc\\x{300}\";\nprint md5hex($str), \"\\n\";  # croaks\n# Wide character in subroutine entry\n\nWhat you can do is calculate the MD5 checksum of the UTF-8\nrepresentation of such strings.  This is achieved by filtering the\nstring through encodeutf8() function:\n\nuse Digest::MD5 qw(md5hex);\nuse Encode qw(encodeutf8);\n\nmy $str = \"abc\\x{300}\";\nprint md5hex(encodeutf8($str)), \"\\n\";\n# 8c2d46911f3f5a326455f0ed7a8ed3b3\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "Digest, Digest::MD2, Digest::SHA, Digest::HMAC\n\nmd5sum(1)\n\nRFC 1321\n\nhttp://en.wikipedia.org/wiki/MD5\n\nThe paper \"How to Break MD5 and Other Hash Functions\" by Xiaoyun Wang\nand Hongbo Yu.\n",
                "subsections": []
            },
            "COPYRIGHT": {
                "content": "This library is free software; you can redistribute it and/or modify it\nunder the same terms as Perl itself.\n\nCopyright 1998-2003 Gisle Aas.\nCopyright 1995-1996 Neil Winton.\nCopyright 1991-1992 RSA Data Security, Inc.\n\nThe MD5 algorithm is defined in RFC 1321. This implementation is\nderived from the reference C code in RFC 1321 which is covered by the\nfollowing copyright statement:\n\no   Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All\nrights reserved.\n\nLicense to copy and use this software is granted provided that it\nis identified as the \"RSA Data Security, Inc. MD5 Message-Digest\nAlgorithm\" in all material mentioning or referencing this software\nor this function.\n\nLicense is also granted to make and use derivative works provided\nthat such works are identified as \"derived from the RSA Data\nSecurity, Inc. MD5 Message-Digest Algorithm\" in all material\nmentioning or referencing the derived work.\n\nRSA Data Security, Inc. makes no representations concerning either\nthe merchantability of this software or the suitability of this\nsoftware for any particular purpose. It is provided \"as is\" without\nexpress or implied warranty of any kind.\n\nThese notices must be retained in any copies of any part of this\ndocumentation and/or software.\n\nThis copyright does not prohibit distribution of any version of Perl\ncontaining this extension under the terms of the GNU or Artistic\nlicenses.\n",
                "subsections": []
            },
            "AUTHORS": {
                "content": "The original \"MD5\" interface was written by Neil Winton\n(\"N.Winton@axion.bt.co.uk\").\n\nThe \"Digest::MD5\" module is written by Gisle Aas\n<gisle@ActiveState.com>.\n\nperl v5.34.0                      2026-06-23                Digest::MD5(3perl)",
                "subsections": []
            }
        }
    }
}