当前位置:网站首页>TLV decoding
TLV decoding
2022-06-25 17:42:00 【Python Encyclopedia】
key = input()
str = input().split(" ")
i = 0
while i < len(str):
tag = str[i]
length = int(str[i + 2] + str[i + 1], 16)
value = ""
for j in range(length):
value += str[i+3+j]+" "
i = i+3+length
if key == tag:
print(value) Title Description :
TLV The coding is according to [ Tag Length Value ] Format to encode , The cells in a code stream are Tag identification , Tag In the code stream The only one that doesn't repeat ,Length Represents a cell Value The length of ,Value Represents the value of the cell .
The code stream is in the form of a cell Tag start ,Tag Fixed occupation A byte ,Length Fixed occupation Two bytes , The byte order is Small end of the sequence .
Now given TLV Format coded code stream , And the cells that need to be decoded Tag, Please output... Of this cell Value.
Of the input bitstream 16 In hexadecimal characters , Excluding lowercase letters , And required output 16 Do not include lowercase letters in the hexadecimal string ;
The maximum length of the code stream string does not exceed 50000 Bytes .
Input description :
The first line of input is a string , Represents... Of the cell to be decoded Tag ;
The second input behavior of a string , Indicates the to be decoded 16 Base stream , Use... Between bytes The blank space to separate .
Output description :
Output a string , Indicates the cell to be decoded in 16 In base notation Value .
Example 1 :
Input
31
32 01 00 AE 90 02 00 01 02 30 03 00 AB 32 31 31 02 00 32 33 33 01 00 CC
1
2
Output
32 33
1
explain
Need to parse the cell Tag yes 31, Start matching from the beginning of the code stream ,
Tag by 32 The cell length of is 1(01 00, The small end order is expressed as 1);
Of the second cell Tag yes 90, The length of 2;
Of the third cell Tag yes 30, The length of 3;
Of the fourth cell Tag yes 31, The length of 2(02 00), So just return the last two bytes of the length , namely 32 33.
边栏推荐
- 【Matlab】数据统计分析
- Treasure and niche Chinese painting 3D texture material website sharing
- Acy100 oil fume concentration online monitor for kitchen oil fume emission in catering industry
- 有关QueryInterface函数
- Learning Tai Chi maker mqtt (II) basic principles of mqtt
- Mathematical modeling - nonlinear programming
- Agent white paper - jointly build agents and create the wisdom of the whole scene | cloud library No.21 recommendation
- 超全金屬PBR多通道貼圖素材網站整理
- Is Guotai Junan Securities reliable? Is it legal? Is it safe to open a stock account?
- js禁止浏览器默认事件
猜你喜欢

配电室环境的分布式远程管理

杰理之获取复位源和唤醒的 IO 口的方法【篇】

win10安装cuda的操作步骤(不断完美中)
![Jerry's addition of encrypted file playback function [chapter]](/img/d0/b7a0c9030c157f282405129be51efe.png)
Jerry's addition of encrypted file playback function [chapter]

Mathematical modeling -- integer programming

【UVM实战 ===> Episode_2 】~ VIP、VIP的开发、VIP的发布

Learn Tai Chi Maker - mqtt (III) connect to mqtt server
![[compilation principle] lexical analysis](/img/b2/8f7dea3944839e27199b28d903d9f0.png)
[compilation principle] lexical analysis

A development of student management system based on PHP

杰理之如何给外界输出一个时钟源使用【篇】
随机推荐
Learn Tai Chi Maker - mqtt (III) connect to mqtt server
Comprehensive optimization of the six topics, Alibaba performance optimization booklet open source, leading you to the ultimate performance
杰理之SPI 从机使用注意事项【篇】
Py3.6 and py3.7 installed by CONDA
杰理之唤醒口使用注意事项【篇】
Distinguishing seven kinds of facial expressions by deep separable convolution neural network
Automatic submission for the next education day
Distributed remote management of distribution room environment
CGI connects to database through ODBC
Vscode automatically generates ifndef define ENDIF of header file
Kotlin入门(20)几种常见的对话框
杰理之系统时钟设置出现复位或无效问题【篇】
揭秘GES超大规模图计算引擎HyG:图切分
杰理之定时器使用注意事项【篇】
Create a new ar fashion experience with cheese and sugar beans
Intelligent dialog 01 redis installation
Next. JS hot update markdown file change
Treasure and niche Chinese painting 3D texture material website sharing
Precautions for the use of Jerry's wake-up mouth [chapter]
一些常用的知识点积累