Class: Pubnub::Crypto::Cryptor

Inherits:
Object
  • Object
show all
Defined in:
lib/pubnub/modules/crypto/cryptor.rb

Overview

Base class which is used to implement cryptor that should be used with CryptorProvider implementation for data encryption and decryption.

Direct Known Subclasses

AesCbcCryptor, LegacyCryptor

Instance Method Summary collapse

Instance Method Details

#decrypt(data) ⇒ String?

Decrypt provided data.

Parameters:

Returns:

  • (String, nil)

    Decrypted data or nil in case of decryption error.

Raises:

  • (NotImplementedError)


68
69
70
# File 'lib/pubnub/modules/crypto/cryptor.rb', line 68

def decrypt(data)
  raise NotImplementedError, 'Subclass should provide "decrypt" method implementation.'
end

#encrypt(data) ⇒ EncryptedData?

Encrypt provided data.

Parameters:

  • data (String)

    Source data for encryption.

Returns:

  • (EncryptedData, nil)

    Encrypted data or nil in case of encryption error.

Raises:

  • (NotImplementedError)


59
60
61
# File 'lib/pubnub/modules/crypto/cryptor.rb', line 59

def encrypt(data)
  raise NotImplementedError, 'Subclass should provide "encrypt" method implementation.'
end

#identifierString

Identifier will be encoded into cryptor data header and passed along with encrypted data and metadata.

The identifier must be 4 bytes long.

Returns:

  • (String)

    Unique cryptor identifier.

Raises:

  • (NotImplementedError)


50
51
52
# File 'lib/pubnub/modules/crypto/cryptor.rb', line 50

def identifier
  raise NotImplementedError, 'Subclass should provide "identifier" method implementation.'
end