[Python] Pyasn1 enumerated type encodes as hex, how do I get decimal

Discussão em 'Python' iniciado por Stack, Abril 11, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to code the following using pyasn1


    From RFC7906
    ​

    KeyPurpose ::= ENUMERATED {

    n-a (0), -- Not Applicable
    A (65), -- Operational
    B (66), -- Compatible Multiple Key
    L (76), -- Logistics Combinations
    M (77), -- Maintenance
    R (82), -- Reference
    S (83), -- Sample
    T (84), -- Training
    V (86), -- Developmental
    X (88), -- Exercise
    Z (90), -- "On the Air" Testing
    ... -- Expect additional key purpose values -- }


    I have done this using the documentation, except for the fact when I instantiate using 'V', the asn1parser outputs 56 rather than 86. I believe I've been given the hex representation rather than the decimal I am looking for.

    I have tried following the variable through the debugger and my code pulls out the 86 without issue, so I believe this happens when I use the

    encode(data)

    command. Is there a way to represent this as decimal in the output?

    Continue reading...

Compartilhe esta Página