Sha256: c2fe9ea4f225636d05086a1b4998448a880502350b720bd834c3ea0b43e63bb4
Contents?: true
Size: 618 Bytes
Versions: 6
Compression:
Stored size: 618 Bytes
Contents
# frozen_string_literal: true require 'aead' module Noise module Functions module Cipher class AesGcm def encrypt(k, n, ad, plaintext) mode = AEAD::Cipher.new('AES-256-GCM') cipher = mode.new(k) cipher.encrypt(nonce_to_bytes(n), ad, plaintext) end def decrypt(k, n, ad, ciphertext) mode = AEAD::Cipher.new('AES-256-GCM') cipher = mode.new(k) cipher.decrypt(nonce_to_bytes(n), ad, ciphertext) end def nonce_to_bytes(n) "\00" * 4 + format('%16x', n).htb end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems