Class: Karafka::Pro::Encryption::Cipher

Inherits:
Object
  • Object
show all
Defined in:
lib/karafka/pro/encryption/cipher.rb

Overview

Cipher for encrypting and decrypting data

Instance Method Summary collapse

Constructor Details

#initializeCipher

Initializes the cipher with empty private keys cache



33
34
35
# File 'lib/karafka/pro/encryption/cipher.rb', line 33

def initialize
  @private_pems = {}
end

Instance Method Details

#decrypt(version, content) ⇒ String

Decrypts provided content using version key

Parameters:

  • encryption version

  • encrypted content

Returns:

  • decrypted content



48
49
50
# File 'lib/karafka/pro/encryption/cipher.rb', line 48

def decrypt(version, content)
  private_pem(version).private_decrypt(content)
end

#encrypt(content) ⇒ String

Encrypts given string content with the public key

Parameters:

Returns:



40
41
42
# File 'lib/karafka/pro/encryption/cipher.rb', line 40

def encrypt(content)
  public_pem.public_encrypt(content)
end