Class: Necropsy::DefinitionIdentity::CanonicalDigest
- Inherits:
-
Object
- Object
- Necropsy::DefinitionIdentity::CanonicalDigest
- Defined in:
- lib/necropsy/definition_identity/canonical_digest.rb
Defined Under Namespace
Classes: ByteBudget, DigestOutput, StringOutput
Constant Summary collapse
- MAX_DEPTH =
256- MAX_ITEMS =
1_000_000- MAX_SCALAR_BYTES =
64 * 1024 * 1024
- MAX_TOTAL_BYTES =
256 * 1024 * 1024
Instance Method Summary collapse
- #hexdigest(value) ⇒ Object
- #hexdigest_payload(values) ⇒ Object
-
#initialize(max_depth: MAX_DEPTH, max_items: MAX_ITEMS, max_scalar_bytes: MAX_SCALAR_BYTES, max_total_bytes: MAX_TOTAL_BYTES) ⇒ CanonicalDigest
constructor
A new instance of CanonicalDigest.
Constructor Details
#initialize(max_depth: MAX_DEPTH, max_items: MAX_ITEMS, max_scalar_bytes: MAX_SCALAR_BYTES, max_total_bytes: MAX_TOTAL_BYTES) ⇒ CanonicalDigest
Returns a new instance of CanonicalDigest.
19 20 21 22 23 24 25 |
# File 'lib/necropsy/definition_identity/canonical_digest.rb', line 19 def initialize(max_depth: MAX_DEPTH, max_items: MAX_ITEMS, max_scalar_bytes: MAX_SCALAR_BYTES, max_total_bytes: MAX_TOTAL_BYTES) @max_depth = positive_limit(max_depth, :max_depth) @max_items = positive_limit(max_items, :max_items) @max_scalar_bytes = positive_limit(max_scalar_bytes, :max_scalar_bytes) @max_total_bytes = positive_limit(max_total_bytes, :max_total_bytes) end |
Instance Method Details
#hexdigest(value) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/necropsy/definition_identity/canonical_digest.rb', line 27 def hexdigest(value) reset_state output = DigestOutput.new(byte_budget) process([[:value, value, 0, output]]) output.hexdigest end |
#hexdigest_payload(values) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/necropsy/definition_identity/canonical_digest.rb', line 34 def hexdigest_payload(values) reset_state output = DigestOutput.new(byte_budget) output.write('[') values.each_with_index do |value, index| count_item! output.write(',') if index.positive? output.write(payload_scalar(value)) end output.write(']') output.hexdigest end |