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

Returns a new instance of Cipher.



19
20
21
# File 'lib/karafka/pro/encryption/cipher.rb', line 19

def initialize
  @private_pems = {}
end

Instance Method Details

#decrypt(version, content) ⇒ String

Decrypts provided content using ‘version` key

Parameters:

  • version (String)

    encryption version

  • content (String)

    encrypted content

Returns:

  • (String)

    decrypted content



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

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

#encrypt(content) ⇒ String

Encrypts given string content with the public key

Parameters:

  • content (String)

Returns:

  • (String)


26
27
28
# File 'lib/karafka/pro/encryption/cipher.rb', line 26

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