Asn1 der primitive encode
asn1-der-primitive-encode · version 1.0.0 · Structured formats · free, no key needed
Encode one universal DER primitive from typed fields into lowercase hex.
Use when you need to: encode one der primitive value · build an asn.1 universal tlv · write der boolean integer and null.
Decide before calling
Read the versioned contract and the supported scope below. Reuse asn1-der-primitive-encode@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.
Explain the choice
"I can use asn1-der-primitive-encode@1.0.0 for encode one der primitive value. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."
Supported
- encode one der primitive value
- build an asn.1 universal tlv
- write der boolean integer and null
- encode der bit string and octet string
- encode der utctime or generalizedtime
- build an object identifier tlv from arcs
- typed primitive fields into lowercase hex
- קידוד ערך פרימיטיבי אחד
Not supported
- decode a der hex value
- format object identifier arcs as brace notation
- constructed or indefinite ber encodings
- sign or encrypt the encoded value
Behavior
- One primitive universal value per call. The caller passes type_name and only that type's fields. NULL has no other field. OBJECT IDENTIFIER takes an arcs array of canonical decimal strings, not notation text.
- Integers are canonical decimal strings (no sign on zero, no leading zeros). Bytes are lowercase hex. TRUE is ff and FALSE is 00. BIT STRING unused bits are 0..7 and the unused bits themselves are zero.
- Length is the definite minimum form. Strings are primitive. UTCTime is exactly YYMMDDHHMMSSZ. GeneralizedTime is YYYYMMDDHHMMSSZ or YYYYMMDDHHMMSS.fractionZ with a point, no comma, and no trailing zero in the fraction. No local offset and no leap second.
- max_value_bytes applies to a present integer or text string and is checked before syntax, even when that field does not belong to type_name. max_payload_hex_chars applies to a present payload_hex string the same way.
- max_oid_arcs and max_oid_arc_digits apply only when arcs is an array on an object_identifier value: the array length is checked before item syntax, then each arc string's length is checked before the digit grammar. No other arc cap is enforced.
- A field that does not belong to type_name, a non-canonical integer, or a DER rule failure is invalid_input. type_name outside the selected set is invalid_input.
- Disclaimer: format transform only; provides no confidentiality, integrity, or authenticity.
Input
type_name(one of "boolean", "integer", "bit_string", "octet_string", "null", "object_identifier", "utf8_string", "numeric_string", "printable_string", "ia5_string", "utc_time", "generalized_time", "visible_string", required)boolean(boolean, optional)integer(string, optional): min length 1; max length 256; pattern^(0|-?[1-9][0-9]*)$unused_bits(integer, optional): min 0; max 7payload_hex(string, optional): max length 512; pattern^(?:[0-9a-f]{2})*$arcs(array of string, optional): min items 2; max items 32; each min length 1; each max length 48; each pattern^(0|[1-9][0-9]*)$text(string, optional): max length 256
Output
der_hex(string, required): min length 4; max length 4096; pattern^(?:[0-9a-f]{2})*$
Limits
- max value bytes: 256
- max payload hex chars: 512
- max oid arcs: 32
- max oid arc digits: 48
Example
Request input:
{
"type_name": "null"
}
Response:
{
"result": {
"der_hex": "0500"
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "asn1-der-primitive-encode",
"version": "1.0.0",
"input": {
"type_name": "null"
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/asn1-der-primitive-encode/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"type_name":"null"}'
The machine-readable contract is at /v1/tools/asn1-der-primitive-encode/versions/1.0.0.
CLI
node cli.mjs run asn1-der-primitive-encode 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Asn1 der primitive decode: Decode one universal DER primitive from lowercase hex into typed fields.
- Asn1 der encode tree: Encode a schema-free ASN.1 node list as one canonical DER value.
- Asn1 der parse: Parse one ASN.1 DER value into a flat schema-free TLV node list.
- Toml10 format: Emit canonical TOML 1.0 source from a typed document tree.
- Xpath10 evaluate: Evaluate an XPath 1.0 value expression and return its type with an exact string, number, or boolean token.
- Asn1 der node extract: Extract one DER node by a numeric path, with header, content, and child paths.