本文簡要介紹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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
