├── Format JSON ├── Format XML ├── PEM ASN.1 Decode ├── PEM X509 Decode ├── Remove Whitespace ├── URL Encode ├── URL Decode ├── Base64 Encode ├── Base64 X509 Decode ├── Base64 Decode ├── Base64 to Hex ├── Hex to Base64 ├── Base64 to PEM X509 ├── Base64URL Encode ├── Base64URL Decode ├── SAMLRequest GET Encode ├── JWT Decode ├── Base64 to Decimal ├── SAMLRequest GET Decode ├── README.md ├── Base64 to HEX Dump ├── Base64 to ModHex └── ModHex to Base64 /Format JSON: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # IN: JSON 4 | # OUT: JSON (reformatted) 5 | 6 | # Check if jq is available 7 | if ! command -v jq &> /dev/null 8 | then 9 | echo "jq could not be found" 10 | exit 1 11 | fi 12 | 13 | jq . -------------------------------------------------------------------------------- /Format XML: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # IN: XML 4 | # OUT: XML (reformatted) 5 | 6 | # Check is xmllint is available 7 | if ! command -v xmllint &> /dev/null 8 | then 9 | echo "xmllint could not be found" 10 | exit 1 11 | fi 12 | 13 | xmllint --c14n - | XMLLINT_INDENT=$'\t' xmllint --encode UTF-8 --format - -------------------------------------------------------------------------------- /PEM ASN.1 Decode: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # IN: PEM formatted data 4 | # OUT: ASN.1 dump (using openssl) 5 | 6 | # Check if openssl is available 7 | if ! command -v openssl &> /dev/null 8 | then 9 | echo "openssl could not be found" 10 | exit 1 11 | fi 12 | 13 | openssl asn1parse -inform PEM -dump -i -in "$1" 14 | -------------------------------------------------------------------------------- /PEM X509 Decode: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # IN: X.509 certificate in PEM format 4 | # OUT: Decoded certificate (using openssl) 5 | 6 | # Check if openssl is available 7 | if ! command -v openssl &> /dev/null 8 | then 9 | echo "openssl could not be found" 10 | exit 1 11 | fi 12 | 13 | openssl x509 -inform PEM -text -fingerprint 14 | -------------------------------------------------------------------------------- /Remove Whitespace: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | /dev/null 2>&1 && pwd )" 10 | 11 | # Send stdin to the "Base64 to PEM X590" filter and then to the "PEM X509 Decode" filter 12 | "$DIR/Base64 to PEM X509" | "$DIR/PEM X509 Decode" -------------------------------------------------------------------------------- /Base64 Decode: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | /dev/null 2>&1 && pwd )" 17 | 18 | # Use the "Base64URL Decode" filter to decode the header 19 | header=$(echo "${parts[0]}" | "$DIR/Base64URL Decode") 20 | # Use the "Base64URL Decode" filter to decode the payload 21 | payload=$(echo "${parts[1]}" | "$DIR/Base64URL Decode") 22 | # Leave the signature as is 23 | signature="${parts[2]}" 24 | 25 | echo "Header: $header" 26 | echo "Payload: $payload" 27 | echo "Signature: $signature" 28 | 29 | exit 0 -------------------------------------------------------------------------------- /Base64 to Decimal: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | "Apply Text Filter" menu. 13 | And in the Filters Palette (Window -> Palettes -> Text Filters). 14 | 15 | The filters use different shell commands that are not installed by default on macOS. Install them via e.g. 16 | [Macports](https://www.macports.org/) or [Homebrew](https://brew.sh/). The shell commands must be in your path. The commands used are: 17 | - `php` (used by many filters) 18 | - `openssl` (for certificate / ASN.1 filters) 19 | - `jq` (for Format JSON) 20 | - `xmllint` (for Format XML) 21 | 22 | Enjoy! -------------------------------------------------------------------------------- /Base64 to HEX Dump: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | = 0x20 && $i <= 0x7E) ? chr($i) : $pad; 24 | } 25 | } 26 | 27 | $hex = str_split(bin2hex($data), $width*2); 28 | $chars = str_split(strtr($data, $from, $to), $width); 29 | 30 | $offset = 0; 31 | foreach ($hex as $i => $line) 32 | { 33 | echo sprintf('%6X',$offset).' : '.implode(' ', str_split($line,2)) . ' [' . $chars[$i] . ']' . $newline; 34 | $offset += $width; 35 | } 36 | } 37 | 38 | $in=''; 39 | while (!feof(STDIN)) 40 | { 41 | $res = fread(STDIN, 1024); 42 | if (false === $res) 43 | { 44 | fwrite(STDERR, "error reading from stdin"); 45 | exit(3); 46 | } 47 | $in .= $res; 48 | } 49 | $bin=base64_decode($in); 50 | if (false===$bin) 51 | { 52 | fwrite(STDERR, "base64_encode failed"); 53 | exit(3); 54 | } 55 | 56 | $result=hex_dump($bin); 57 | 58 | fwrite(STDOUT, $result); 59 | 60 | exit(0); 61 | -------------------------------------------------------------------------------- /Base64 to ModHex: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | > 4) & 0xf]; 78 | $encoded .= $TRANSKEY[ (int)$bin & 0xf]; 79 | } 80 | return $encoded; 81 | } -------------------------------------------------------------------------------- /ModHex to Base64: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 |