Module: Sekret

Defined in:
lib/sekret.rb,
lib/sekret/cli.rb,
lib/sekret/errors.rb,
lib/sekret/header.rb,
lib/sekret/encoder.rb,
lib/sekret/version.rb,
lib/sekret/checksum.rb,
lib/sekret/decryptor.rb,
lib/sekret/encryptor.rb,
lib/sekret/cli/runner.rb,
lib/sekret/configuration.rb,
lib/sekret/key_generator.rb,
lib/sekret/body_encryption.rb

Overview

Used for encrypting/decrypting data

Defined Under Namespace

Modules: CLI, Errors Classes: BodyEncryption, Checksum, Configuration, Decryptor, Encoder, Encryptor, Header, KeyGenerator

Constant Summary collapse

VERSION =

The current version of Sekret

'1.0.0'.freeze
CONFIG_MUTEX =

The config lock

Mutex.new

Class Method Summary collapse

Class Method Details

.configConfiguration

Retuns a new config

Returns:



20
21
22
23
24
# File 'lib/sekret/configuration.rb', line 20

def self.config
  CONFIG_MUTEX.synchronize do
    @config ||= Configuration.new(nil, nil, nil)
  end
end

.configure {|config| ... } ⇒ Object

Configuration

Yields:



28
29
30
# File 'lib/sekret/configuration.rb', line 28

def self.configure
  yield config
end

.decrypt(message) ⇒ String

Decrypt the passed payload

Parameters:

  • message (String)

    the encrypted message to decrypt

Returns:

  • (String)

    The un-encrypted payload



27
28
29
# File 'lib/sekret.rb', line 27

def self.decrypt(message)
  Sekret::Decryptor.new(Sekret.config.public_key, message).call
end

.encrypt(payload) ⇒ String

Encrypt the passed payload

Parameters:

  • payload (String)

    The plaintext to encrypt

Returns:

  • (String)

    The encrypted payload



17
18
19
# File 'lib/sekret.rb', line 17

def self.encrypt(payload)
  Sekret::Encryptor.new(Sekret.config.private_key, payload).call
end