mirror of
https://github.com/wader/fq.git
synced 2024-11-22 07:16:49 +03:00
asn1_ber: Add more doc and multiple outputs for frompem
This commit is contained in:
parent
ac4d15ccb9
commit
0312c92c31
@ -118,6 +118,17 @@ Supports `torepr` but without schema support it's not that useful:
|
||||
fq -d asn1_ber torepr file.ber
|
||||
```
|
||||
|
||||
There is also `frompem` and `topem` to help working with PEM format:
|
||||
|
||||
```
|
||||
fq -d raw 'frompem | asn1_ber | d' cert.pem
|
||||
```
|
||||
|
||||
If the schema is known and not that complicated it can be reproduced:
|
||||
|
||||
```
|
||||
fq -d asn1_ber 'torepr as $r | ["version", "modulus", "private_exponent", "private_exponen", "prime1", "prime2", "exponent1", "exponent2", "coefficient"] | with_entries({key: .value, value: $r[.key]})' pkcs1.der
|
||||
```
|
||||
### becode
|
||||
|
||||
Supports `torepr`:
|
||||
|
@ -5,3 +5,15 @@ Supports `torepr` but without schema support it's not that useful:
|
||||
```
|
||||
fq -d asn1_ber torepr file.ber
|
||||
```
|
||||
|
||||
There is also `frompem` and `topem` to help working with PEM format:
|
||||
|
||||
```
|
||||
fq -d raw 'frompem | asn1_ber | d' cert.pem
|
||||
```
|
||||
|
||||
If the schema is known and not that complicated it can be reproduced:
|
||||
|
||||
```
|
||||
fq -d asn1_ber 'torepr as $r | ["version", "modulus", "private_exponent", "private_exponen", "prime1", "prime2", "exponent1", "exponent2", "coefficient"] | with_entries({key: .value, value: $r[.key]})' pkcs1.der
|
||||
```
|
@ -332,7 +332,7 @@ def diff($a; $b):
|
||||
def frompem:
|
||||
( tobytes
|
||||
| tostring
|
||||
| first(capture("-----BEGIN(.*?)-----(?<s>.*?)-----END(.*?)-----"; "m")).s
|
||||
| capture("-----BEGIN(.*?)-----(?<s>.*?)-----END(.*?)-----"; "mg").s
|
||||
| base64
|
||||
) // error("no pem header or footer found");
|
||||
|
||||
|
3
pkg/interp/testdata/funcs.fqtest
vendored
3
pkg/interp/testdata/funcs.fqtest
vendored
@ -1,7 +1,8 @@
|
||||
$ fq -i
|
||||
null> "abc" | topem
|
||||
"-----BEGIN-----\nYWJj\n-----END-----\n"
|
||||
null> "abc" | topem | frompem | tostring
|
||||
null> "abc" | topem | "before" + . + "between" + . + "after" | frompem | tostring
|
||||
"abc"
|
||||
"abc"
|
||||
null>
|
||||
null> ^D
|
||||
|
Loading…
Reference in New Issue
Block a user