{
    "content": [
        {
            "type": "text",
            "text": "# Crypt::Misc (perldoc)\n\n## NAME\n\nCrypt::Misc - miscellaneous functions related to (or used by) CryptX\n\n## SYNOPSIS\n\nThis module contains a collection of mostly unsorted functions loosely-related to CryptX\ndistribution but not implementing cryptography.\nMost of them are also available in other perl modules but once you utilize CryptX you might\navoid dependencies on other modules by using functions from Crypt::Misc.\n\n## DESCRIPTION\n\nuse Crypt::Misc ':all';\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **FUNCTIONS**\n- **SEE ALSO**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Crypt::Misc",
        "section": "",
        "mode": "perldoc",
        "summary": "Crypt::Misc - miscellaneous functions related to (or used by) CryptX",
        "synopsis": "This module contains a collection of mostly unsorted functions loosely-related to CryptX\ndistribution but not implementing cryptography.\nMost of them are also available in other perl modules but once you utilize CryptX you might\navoid dependencies on other modules by using functions from Crypt::Misc.",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 6,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 19,
                "subsections": []
            },
            {
                "name": "FUNCTIONS",
                "lines": 240,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Crypt::Misc - miscellaneous functions related to (or used by) CryptX\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "This module contains a collection of mostly unsorted functions loosely-related to CryptX\ndistribution but not implementing cryptography.\n\nMost of them are also available in other perl modules but once you utilize CryptX you might\navoid dependencies on other modules by using functions from Crypt::Misc.\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "use Crypt::Misc ':all';\n\n# Base64 and Base64/URL-safe functions\n$base64    = encodeb64($rawbytes);\n$rawbytes  = decodeb64($base64);\n$base64url = encodeb64u($encodeb64u);\n$rawbytes  = decodeb64u($base64url);\n\n# read/write file\n$rawdata = readrawfile($filename);\nwriterawfile($filename, $rawdata);\n\n# convert PEM/DER\n$derdata = pemtoder($pemdata);\n$pemdata = dertopem($derdata);\n\n# others\ndie \"mismatch\" unless sloweq($str1, $str2);\n",
                "subsections": []
            },
            "FUNCTIONS": {
                "content": "By default, Crypt::Misc doesn't import any function. You can import individual functions like\nthis:\n\nuse Crypt::Misc qw(readrawfile);\n\nOr import all available functions:\n\nuse Crypt::Misc ':all';\n\nreadrawfile\n*Since: 0.029*\n\n$rawdata = readrawfile($filename);\n\nRead file $filename into a scalar as a binary data (without decoding/transformation).\n\nwriterawfile\n*Since: 0.029*\n\nwriterawfile($filename, $rawdata);\n\nWrite $rawdata to file $filename as binary data.\n\nsloweq\n*Since: 0.029*\n\nif (sloweq($data1, $data2)) { ... }\n\nConstant time compare (to avoid timing side-channel).\n\npemtoder\n*Since: 0.029*\n\n$derdata = pemtoder($pemdata);\n#or\n$derdata = pemtoder($pemdata, $password);\n\nConvert PEM to DER representation. Supports also password protected PEM data.\n\ndertopem\n*Since: 0.029*\n\n$pemdata = dertopem($derdata, $headername);\n#or\n$pemdata = dertopem($derdata, $headername, $password);\n#or\n$pemdata = dertopem($derdata, $headername, $passord, $ciphername);\n\n# $headername e.g. \"PUBLIC KEY\", \"RSA PRIVATE KEY\" ...\n# $ciphername e.g. \"DES-EDE3-CBC\", \"AES-256-CBC\" (DEFAULT) ...\n\nConvert DER to PEM representation. Supports also password protected PEM data.\n\nrandomv4uuid\n*Since: 0.031*\n\nmy $uuid = randomv4uuid();\n\nReturns cryptographically strong Version 4 random UUID: \"xxxxxxxx-xxxx-4xxx-Yxxx-xxxxxxxxxxxx\"\nwhere \"x\" is any hexadecimal digit and \"Y\" is one of 8, 9, A, B (1000, 1001, 1010, 1011) e.g.\n\"f47ac10b-58cc-4372-a567-0e02b2c3d479\".\n\nisv4uuid\n*Since: 0.031*\n\nif (isv4uuid($uuid)) {\n...\n}\n\nChecks the given $uuid string whether it matches V4 UUID format and returns 0 (mismatch) or 1\n(match).\n\nincrementoctetsle\n*Since: 0.048*\n\n$octects = incrementoctetsle($octets);\n\nTake input $octets as a little-endian big number and return an increment.\n\nincrementoctetsbe\n*Since: 0.048*\n\n$octects = incrementoctetsbe($octets);\n\nTake input $octets as a big-endian big number and return an increment.\n\nencodeb64\n*Since: 0.029*\n\n$base64string = encodeb64($rawdata);\n\nEncode $rawbytes into Base64 string, no line-endings in the output string.\n\ndecodeb64\n*Since: 0.029*\n\n$rawdata = decodeb64($base64string);\n\nDecode a Base64 string.\n\nencodeb64u\n*Since: 0.029*\n\n$base64urlstring = encodeb64($rawdata);\n\nEncode $rawbytes into Base64/URL-Safe string, no line-endings in the output string.\n\ndecodeb64u\n*Since: 0.029*\n\n$rawdata = decodeb64($base64urlstring);\n\nDecode a Base64/URL-Safe string.\n\nencodeb32r\n*Since: 0.049*\n\n$string = encodeb32r($rawdata);\n\nEncode bytes into Base32 (rfc4648 alphabet) string, without \"=\" padding.\n\ndecodeb32r\n*Since: 0.049*\n\n$rawdata = decodeb32r($string);\n\nDecode a Base32 (rfc4648 alphabet) string into bytes.\n\nencodeb32b\n*Since: 0.049*\n\n$string = encodeb32b($rawdata);\n\nEncode bytes into Base32 (base32hex alphabet) string, without \"=\" padding.\n\ndecodeb32b\n*Since: 0.049*\n\n$rawdata = decodeb32b($string);\n\nDecode a Base32 (base32hex alphabet) string into bytes.\n\nencodeb32z\n*Since: 0.049*\n\n$string = encodeb32z($rawdata);\n\nEncode bytes into Base32 (zbase32 alphabet) string.\n\ndecodeb32z\n*Since: 0.049*\n\n$rawdata = decodeb32z($string);\n\nDecode a Base32 (zbase32 alphabet) string into bytes.\n\nencodeb32c\n*Since: 0.049*\n\n$string = encodeb32c($rawdata);\n\nEncode bytes into Base32 (crockford alphabet) string.\n\ndecodeb32c\n*Since: 0.049*\n\n$rawdata = decodeb32c($string);\n\nDecode a Base32 (crockford alphabet) string into bytes.\n\nencodeb58b\n*Since: 0.049*\n\n$string = encodeb58b($rawdata);\n\nEncode bytes into Base58 (Bitcoin alphabet) string.\n\ndecodeb58b\n*Since: 0.049*\n\n$rawdata = decodeb58b($string);\n\nDecode a Base58 (Bitcoin alphabet) string into bytes.\n\nencodeb58f\n*Since: 0.049*\n\n$string = encodeb58f($rawdata);\n\nEncode bytes into Base58 (Flickr alphabet) string.\n\ndecodeb58f\n*Since: 0.049*\n\n$rawdata = decodeb58f($string);\n\nDecode a Base58 (Flickr alphabet) string into bytes.\n\nencodeb58r\n*Since: 0.049*\n\n$string = encodeb58r($rawdata);\n\nEncode bytes into Base58 (Ripple alphabet) string.\n\ndecodeb58r\n*Since: 0.049*\n\n$rawdata = decodeb58r($string);\n\nDecode a Base58 (Ripple alphabet) string into bytes.\n\nencodeb58t\n*Since: 0.049*\n\n$string = encodeb58t($rawdata);\n\nEncode bytes into Base58 (Tipple alphabet) string.\n\ndecodeb58t\n*Since: 0.049*\n\n$rawdata = decodeb58t($string);\n\nDecode a Base58 (Tipple alphabet) string into bytes.\n\nencodeb58s\n*Since: 0.049*\n\n$string = encodeb58s($rawdata);\n\nEncode bytes into Base58 (Stellar alphabet) string.\n\ndecodeb58s\n*Since: 0.049*\n\n$rawdata = decodeb58s($string);\n\nDecode a Base58 (Stellar alphabet) string into bytes.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "*   CryptX\n",
                "subsections": []
            }
        }
    }
}