EncryptorV3

public final class EncryptorV3 : NSObject, RNCryptorType

Format version 3 encryptor. Use this to ensure a specific format verison or when using keys (which are inherrently versions-specific). To use the latest encryptor with a password, use Encryptor instead.

  • Creates and returns an encryptor.

    Declaration

    Swift

    public convenience init(password: String)

    Parameters

    password

    Non-empty password string. This will be interpretted as UTF-8.

  • Creates and returns an encryptor using keys.

    Attention

    This method requires some expertise to use correctly. Most users should use init(password:) which is simpler to use securely.

    Keys should not be generated directly from strings (.dataUsingEncoding() or similar). Ideally, keys should be random (Cryptor.randomDataOfLength() or some other high-quality random generator. If keys must be generated from strings, then use FormatV3.keyForPassword(salt:) with a random salt, or just use password-based encryption (that’s what it’s for).

    • parameters:
      • encryptionKey: AES-256 key. Must be exactly FormatV3.keySize (kCCKeySizeAES256, 32 bytes)
      • hmacKey: HMAC key. Must be exactly FormatV3.keySize (kCCKeySizeAES256, 32 bytes)

    Declaration

    Swift

    public convenience init(encryptionKey: NSData, hmacKey: NSData)

    Parameters

    encryptionKey

    AES-256 key. Must be exactly FormatV3.keySize (kCCKeySizeAES256, 32 bytes)

    hmacKey

    HMAC key. Must be exactly FormatV3.keySize (kCCKeySizeAES256, 32 bytes)

  • Takes a data, returns a processed data, and invalidates the cryptor.

    Declaration

    Swift

    public func encryptData(data: NSData) -> NSData
  • Updates cryptor with data and returns encrypted data.

    Declaration

    Swift

    public func updateWithData(data: NSData) -> NSData

    Parameters

    data

    Data to process. May be empty.

    Return Value

    Processed data. May be empty.

  • Returns trailing data and invalidates the cryptor.

    Declaration

    Swift

    public func finalData() -> NSData

    Return Value

    Trailing data