{
    "content": [
        {
            "type": "text",
            "text": "# Digest (info)\n\n## NAME\n\nDigest - Modules that calculate message digests\n\n## SYNOPSIS\n\n$md5  = Digest->new(\"MD5\");\n$sha1 = Digest->new(\"SHA-1\");\n$sha256 = Digest->new(\"SHA-256\");\n$sha384 = Digest->new(\"SHA-384\");\n$sha512 = Digest->new(\"SHA-512\");\n$hmac = Digest->HMACMD5($key);\n\n## DESCRIPTION\n\nThe \"Digest::\" modules calculate digests, also called \"fingerprints\" or\n\"hashes\", of some data, called a message.  The digest is (usually) some\nsmall/fixed size string.  The actual size of the digest depend of the\nalgorithm used.  The message is simply a sequence of arbitrary bytes or\nbits.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **OO INTERFACE**\n- **Digest speed**\n- **SEE ALSO**\n- **AUTHOR**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Digest",
        "section": "",
        "mode": "info",
        "summary": "Digest - Modules that calculate message digests",
        "synopsis": "$md5  = Digest->new(\"MD5\");\n$sha1 = Digest->new(\"SHA-1\");\n$sha256 = Digest->new(\"SHA-256\");\n$sha384 = Digest->new(\"SHA-384\");\n$sha512 = Digest->new(\"SHA-512\");\n$hmac = Digest->HMACMD5($key);",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 48,
                "subsections": []
            },
            {
                "name": "OO INTERFACE",
                "lines": 114,
                "subsections": []
            },
            {
                "name": "Digest speed",
                "lines": 31,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 11,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 12,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Digest - Modules that calculate message digests\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "$md5  = Digest->new(\"MD5\");\n$sha1 = Digest->new(\"SHA-1\");\n$sha256 = Digest->new(\"SHA-256\");\n$sha384 = Digest->new(\"SHA-384\");\n$sha512 = Digest->new(\"SHA-512\");\n\n$hmac = Digest->HMACMD5($key);\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "The \"Digest::\" modules calculate digests, also called \"fingerprints\" or\n\"hashes\", of some data, called a message.  The digest is (usually) some\nsmall/fixed size string.  The actual size of the digest depend of the\nalgorithm used.  The message is simply a sequence of arbitrary bytes or\nbits.\n\nAn important property of the digest algorithms is that the digest is\nlikely to change if the message change in some way.  Another property\nis that digest functions are one-way functions, that is it should be\nhard to find a message that correspond to some given digest.\nAlgorithms differ in how \"likely\" and how \"hard\", as well as how\nefficient they are to compute.\n\nNote that the properties of the algorithms change over time, as the\nalgorithms are analyzed and machines grow faster.  If your application\nfor instance depends on it being \"impossible\" to generate the same\ndigest for a different message it is wise to make it easy to plug in\nstronger algorithms as the one used grow weaker.  Using the interface\ndocumented here should make it easy to change algorithms later.\n\nAll \"Digest::\" modules provide the same programming interface.  A\nfunctional interface for simple use, as well as an object oriented\ninterface that can handle messages of arbitrary length and which can\nread files directly.\n\nThe digest can be delivered in three formats:\n\nbinary  This is the most compact form, but it is not well suited for\nprinting or embedding in places that can't handle arbitrary\ndata.\n\nhex     A twice as long string of lowercase hexadecimal digits.\n\nbase64  A string of portable printable characters.  This is the base64\nencoded representation of the digest with any trailing padding\nremoved.  The string will be about 30% longer than the binary\nversion.  MIME::Base64 tells you more about this encoding.\n\nThe functional interface is simply importable functions with the same\nname as the algorithm.  The functions take the message as argument and\nreturn the digest.  Example:\n\nuse Digest::MD5 qw(md5);\n$digest = md5($message);\n\nThere are also versions of the functions with \"hex\" or \"base64\"\nappended to the name, which returns the digest in the indicated form.\n",
                "subsections": []
            },
            "OO INTERFACE": {
                "content": "The following methods are available for all \"Digest::\" modules:\n\n$ctx = Digest->XXX($arg,...)\n$ctx = Digest->new(XXX => $arg,...)\n$ctx = Digest::XXX->new($arg,...)\nThe constructor returns some object that encapsulate the state of\nthe message-digest algorithm.  You can add data to the object and\nfinally ask for the digest.  The \"XXX\" should of course be replaced\nby the proper name of the digest algorithm you want to use.\n\nThe two first forms are simply syntactic sugar which automatically\nload the right module on first use.  The second form allow you to\nuse algorithm names which contains letters which are not legal perl\nidentifiers, e.g. \"SHA-1\".  If no implementation for the given\nalgorithm can be found, then an exception is raised.\n\nTo know what arguments (if any) the constructor takes (the\n\"$args,...\" above) consult the docs for the specific digest\nimplementation.\n\nIf new() is called as an instance method (i.e. $ctx->new) it will\njust reset the state the object to the state of a newly created\nobject.  No new object is created in this case, and the return\nvalue is the reference to the object (i.e. $ctx).\n\n$otherctx = $ctx->clone\nThe clone method creates a copy of the digest state object and\nreturns a reference to the copy.\n\n$ctx->reset\nThis is just an alias for $ctx->new.\n\n$ctx->add( $data )\n$ctx->add( $chunk1, $chunk2, ... )\nThe string value of the $data provided as argument is appended to\nthe message we calculate the digest for.  The return value is the\n$ctx object itself.\n\nIf more arguments are provided then they are all appended to the\nmessage, thus all these lines will have the same effect on the\nstate of the $ctx object:\n\n$ctx->add(\"a\"); $ctx->add(\"b\"); $ctx->add(\"c\");\n$ctx->add(\"a\")->add(\"b\")->add(\"c\");\n$ctx->add(\"a\", \"b\", \"c\");\n$ctx->add(\"abc\");\n\nMost algorithms are only defined for strings of bytes and this\nmethod might therefore croak if the provided arguments contain\nchars with ordinal number above 255.\n\n$ctx->addfile( $iohandle )\nThe $iohandle is read until EOF and the content is appended to the\nmessage we calculate the digest for.  The return value is the $ctx\nobject 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$ctx 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 $ctx 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$ctx->addbits( $data, $nbits )\n$ctx->addbits( $bitstring )\nThe addbits() method is an alternative to add() that allow partial\nbytes to be appended to the message.  Most users can just ignore\nthis method since typical applications involve only whole-byte\ndata.\n\nThe two argument form of addbits() will add the first $nbits bits\nfrom $data.  For the last potentially partial byte only the high\norder \"$nbits % 8\" bits are used.  If $nbits is greater than\n\"length($data) * 8\", then this method would do the same as\n\"$ctx->add($data)\".\n\nThe one argument form of addbits() takes a $bitstring of \"1\" and\n\"0\" chars as argument.  It's a shorthand for\n\"$ctx->addbits(pack(\"B*\", $bitstring), length($bitstring))\".\n\nThe return value is the $ctx object itself.\n\nThis example shows two calls that should have the same effect:\n\n$ctx->addbits(\"111100001010\");\n$ctx->addbits(\"\\xF0\\xA0\", 12);\n\nMost digest algorithms are byte based and for these it is not\npossible to add bits that are not a multiple of 8, and the\naddbits() method will croak if you try.\n\n$ctx->digest\nReturn the binary digest for the message.\n\nNote that the \"digest\" operation is effectively a destructive,\nread-once operation. Once it has been performed, the $ctx object is\nautomatically \"reset\" and can be used to calculate another digest\nvalue.  Call $ctx->clone->digest if you want to calculate the\ndigest without resetting the digest state.\n\n$ctx->hexdigest\nSame as $ctx->digest, but will return the digest in hexadecimal\nform.\n\n$ctx->b64digest\nSame as $ctx->digest, but will return the digest as a base64\nencoded string without padding.\n\n$ctx->base64paddeddigest\nSame as $ctx->digest, but will return the digest as a base64\nencoded string.\n",
                "subsections": []
            },
            "Digest speed": {
                "content": "This table should give some indication on the relative speed of\ndifferent algorithms.  It is sorted by throughput based on a benchmark\ndone with of some implementations of this API:\n\nAlgorithm      Size    Implementation                  MB/s\n\nMD4            128     Digest::MD4 v1.3               165.0\nMD5            128     Digest::MD5 v2.33               98.8\nSHA-256        256     Digest::SHA2 v1.1.0             66.7\nSHA-1          160     Digest::SHA v4.3.1              58.9\nSHA-1          160     Digest::SHA1 v2.10              48.8\nSHA-256        256     Digest::SHA v4.3.1              41.3\nHaval-256      256     Digest::Haval256 v1.0.4         39.8\nSHA-384        384     Digest::SHA2 v1.1.0             19.6\nSHA-512        512     Digest::SHA2 v1.1.0             19.3\nSHA-384        384     Digest::SHA v4.3.1              19.2\nSHA-512        512     Digest::SHA v4.3.1              19.2\nWhirlpool      512     Digest::Whirlpool v1.0.2        13.0\nMD2            128     Digest::MD2 v2.03                9.5\n\nAdler-32        32     Digest::Adler32 v0.03            1.3\nCRC-16          16     Digest::CRC v0.05                1.1\nCRC-32          32     Digest::CRC v0.05                1.1\nMD5            128     Digest::Perl::MD5 v1.5           1.0\nCRC-CCITT       16     Digest::CRC v0.05                0.8\n\nThese numbers was achieved Apr 2004 with ActivePerl-5.8.3 running under\nLinux on a P4 2.8 GHz CPU.  The last 5 entries differ by being pure\nperl implementations of the algorithms, which explains why they are so\nslow.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "Digest::Adler32, Digest::CRC, Digest::Haval256, Digest::HMAC,\nDigest::MD2, Digest::MD4, Digest::MD5, Digest::SHA, Digest::SHA1,\nDigest::SHA2, Digest::Whirlpool\n\nNew digest implementations should consider subclassing from\nDigest::base.\n\nMIME::Base64\n\nhttp://en.wikipedia.org/wiki/Cryptographichashfunction\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "Gisle Aas <gisle@aas.no>\n\nThe \"Digest::\" interface is based on the interface originally developed\nby Neil Winton for his \"MD5\" module.\n\nThis library is free software; you can redistribute it and/or modify it\nunder the same terms as Perl itself.\n\nCopyright 1998-2006 Gisle Aas.\nCopyright 1995,1996 Neil Winton.\n\nperl v5.34.0                      2026-06-23                     Digest(3perl)",
                "subsections": []
            }
        }
    }
}