本文简要介绍ruby语言中 OpenSSL::ASN1.traverse
的用法。
用法
OpenSSL::ASN1.traverse(asn1) → nil
如果给出了一个块,它会打印出遇到的每个元素。块参数是(按顺序):
-
depth:递归深度加上遇到的每个构造值(
Integer
) -
offset:当前字节偏移量(
Integer
) -
标头长度:标签和长度标头的组合长度(以字节为单位)。 (
Integer
) -
length:整个数据的总剩余长度(
Integer
) -
构造:此值是否构造(布尔值)
-
tag_class:当前标记类 (
Symbol
) -
tag:当前标签号(
Integer
)
示例
der = File.binread('asn1data.der')
OpenSSL::ASN1.traverse(der) do | depth, offset, header_len, length, constructed, tag_class, tag|
puts "Depth: #{depth} Offset: #{offset} Length: #{length}"
puts "Header length: #{header_len} Tag: #{tag} Tag class: #{tag_class} Constructed: #{constructed}"
end
相关用法
- Ruby ASN1.decode_all用法及代码示例
- Ruby ASN1.decode用法及代码示例
- Ruby ASN1Data.new用法及代码示例
- Ruby ASN1模块用法及代码示例
- Ruby ASN1Data类用法及代码示例
- Ruby Array.push用法及代码示例
- Ruby Array.hash用法及代码示例
- Ruby ARGF.path用法及代码示例
- Ruby Addrinfo.ip_address用法及代码示例
- Ruby Array permutation()用法及代码示例
- Ruby Array.to_a用法及代码示例
- Ruby Array.to_h用法及代码示例
- Ruby Array.to_s用法及代码示例
- Ruby Array class fill()用法及代码示例
- Ruby Array.array + other_array用法及代码示例
- Ruby Array product()用法及代码示例
- Ruby Array zip()用法及代码示例
- Ruby Array concat()用法及代码示例
- Ruby Array类用法及代码示例
- Ruby Addrinfo.connect_from用法及代码示例
- Ruby Array.take()用法及代码示例
- Ruby Array.reject!用法及代码示例
- Ruby Array.flatten!用法及代码示例
- Ruby Array.reject用法及代码示例
- Ruby Array compact!()用法及代码示例
注:本文由纯净天空筛选整理自ruby-lang.org大神的英文原创作品 ASN1.traverse。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。