mirror of
https://github.com/wader/fq.git
synced 2024-11-26 10:33:53 +03:00
e3ae1440c9
Feels less cluttered, easier to read and more consistent. Still keep tovalue, tobytes etc that are more basic functions this only renamed format related functions. Also there is an exceptin for to/fromjson as it comes from jq. Also fixes lots of spelling errors while reading thru.
20 lines
507 B
Plaintext
20 lines
507 B
Plaintext
# https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail
|
|
def from_pem:
|
|
( tobytes
|
|
| tostring
|
|
| capture("-----BEGIN(.*?)-----(?<s>.*?)-----END(.*?)-----"; "mg").s
|
|
| _from_base64({encoding: "std"})
|
|
) // error("no pem header or footer found");
|
|
|
|
def to_pem($label):
|
|
( tobytes
|
|
| _to_base64({encoding: "std"})
|
|
| ($label | if $label != "" then " " + $label end) as $label
|
|
| [ "-----BEGIN\($label)-----"
|
|
, .
|
|
, "-----END\($label)-----"
|
|
, ""
|
|
]
|
|
| join("\n")
|
|
);
|
|
def to_pem: to_pem(""); |