EncryptorV3
public final class EncryptorV3 : 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 useinit(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 useFormatV3.keyForPassword(salt:)
with a random salt, or just use password-based encryption (that’s what it’s for).Declaration
Swift
public convenience init(encryptionKey: Data, hmacKey: Data)
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 encrypt(data: Data) -> Data
-
Updates cryptor with data and returns encrypted data.
Declaration
Swift
public func update(withData data: Data) -> Data
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() -> Data
Return Value
Trailing data