Module: Meshtastic::Unishox2

Defined in:
lib/meshtastic/unishox2.rb

Overview

Default-preset Unishox2, translated from siara-cc/Unishox2 (Apache-2.0), revision 4981d9403de3bdd1938a635ab73f8a2c5a536059. Copyright (C) 2020 Siara Logics (cc). Authors: Arundale Ramanathan, James Z. M. Gao. Ruby adaptation changes: default preset only, bounded strings, strict UTF-8/back-reference validation and explicit malformed-code errors. Apache-2.0 license text is included after END below. No native decoder receives untrusted input. Output and input are bounded.

Constant Summary collapse

MAX_DECODED =
4096

Class Method Summary collapse

Class Method Details

.authors ⇒ Object



19
20
21
# File 'lib/meshtastic/unishox2.rb', line 19

public_class_method def self.authors
  'Unishox2: Arundale Ramanathan, James Z. M. Gao (Apache-2.0); Ruby adaptation: Meshtastic contributors'
end

.decode(opts = {}) ⇒ Object



15
16
17
# File 'lib/meshtastic/unishox2.rb', line 15

public_class_method def self.decode(opts = {})
  Decoder.new(opts.fetch(:payload).to_s.b).decode
end

.help ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/meshtastic/unishox2.rb', line 23

public_class_method def self.help
  puts "USAGE:
    # Decode default-preset Unishox2 compressed text.
    #{self}.decode(payload: 'required - compressed bytes, maximum 4096 decoded bytes')
    # Report codec implementation authors.
    #{self}.authors
  "
end