mirror of
https://github.com/wader/fq.git
synced 2024-11-23 18:56:52 +03:00
cae288e6be
json, yaml, toml, xml, html, csv are now normal formats and most of them also particiate in probing (not html and csv). Also fixes a bunch of bugs in to/fromxml, to/fromjq etc.
20 lines
501 B
Plaintext
20 lines
501 B
Plaintext
# https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail
|
|
def frompem:
|
|
( tobytes
|
|
| tostring
|
|
| capture("-----BEGIN(.*?)-----(?<s>.*?)-----END(.*?)-----"; "mg").s
|
|
| _frombase64({encoding: "std"})
|
|
) // error("no pem header or footer found");
|
|
|
|
def topem($label):
|
|
( tobytes
|
|
| _tobase64({encoding: "std"})
|
|
| ($label | if $label != "" then " " + $label end) as $label
|
|
| [ "-----BEGIN\($label)-----"
|
|
, .
|
|
, "-----END\($label)-----"
|
|
, ""
|
|
]
|
|
| join("\n")
|
|
);
|
|
def topem: topem(""); |