Sha256: af8036e78ebbf30495c6c2bf94e0047781b6d4ac56cee83c6fd290891e25b82e

Contents?: true

Size: 415 Bytes

Versions: 1

Compression:

Stored size: 415 Bytes

Contents

# frozen_string_literal: true

module Lightning
  module Onion
    module ChaCha20
      class OpenSSL
        def self.chacha20_encrypt(key, counter, nonce, plaintext)
          cipher = ::OpenSSL::Cipher.new("ChaCha20")
          cipher.encrypt
          cipher.iv = [counter].pack('V*') + nonce
          cipher.key = key
          cipher.update(plaintext) + cipher.final
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lightning-onion-0.2.10 lib/lightning/onion/chacha20/openssl.rb