RichieCryptor

Objective-C

@protocol RichieCryptor <NSObject>

Swift

protocol RichieCryptor : NSObjectProtocol

RichieCryptor is an interface for encrypting or decrypting data.

  • Call this method repeatedly to feed data into the decrypt/encrypt process. resultHandler will be called with output data, possibly multiple times per call to this method.

    Final invocation needs to pass YES to isFinal. An empty NSData instance can be as input with the final call.

    Note

    If the data provided is to used outside the scope of the callback the data needs to be copied. For performance the same output buffer is reused during processing and thus the contents of the data change.

    Note

    Output data may have different length than input data. Due to padding used by encryption algorithm, when encrypting output can be longer than input, and when decrypting output can be shorter than input.

    Declaration

    Objective-C

    - (BOOL)processData:(nonnull NSData *)input
                isFinal:(BOOL)isFinal
          resultHandler:(void (^_Nonnull)(NSData *_Nonnull))resultHandler;

    Swift

    func processData(_ input: Data, isFinal: Bool, resultHandler: (Data) -> Void) -> Bool

    Return Value

    Boolean indicating success or failure. If failure, the cryptor has failed and cannot continue.