Class: RubyHome::HAP::HTTPEncryption
- Inherits:
-
Object
- Object
- RubyHome::HAP::HTTPEncryption
- Defined in:
- lib/ruby_home/hap/http_encryption.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
Instance Method Summary collapse
- #encrypt(data) ⇒ Object
-
#initialize(key, count: 0) ⇒ HTTPEncryption
constructor
A new instance of HTTPEncryption.
Constructor Details
#initialize(key, count: 0) ⇒ HTTPEncryption
Returns a new instance of HTTPEncryption.
6 7 8 9 |
# File 'lib/ruby_home/hap/http_encryption.rb', line 6 def initialize(key, count: 0) @key = key @count = count end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
22 23 24 |
# File 'lib/ruby_home/hap/http_encryption.rb', line 22 def count @count end |
Instance Method Details
#encrypt(data) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/ruby_home/hap/http_encryption.rb', line 11 def encrypt(data) data.chars.each_slice(1024).map(&:join).map do || additional_data = [.length].pack('v') encrypted_data = chacha20poly1305ietf.encrypt(nonce, , additional_data) increment_count! [additional_data, encrypted_data].join end end |