CacheFile2CleartextInputStream

@interface CacheFile2CleartextInputStream : ZDCInputStream <NSCopying>

Converts from cacheFile (encrypted) format to cleartext (non-encrypted) format.

In other words, the stream takes as input a cacheFile source (via file/stream/data). And as output (what you receive when you invoke -read:maxLength:), it gives you the decrypted/cleartext version.

Use this for reading encrypted files in ZDCCryptoFileFormat_CacheFile.

You can stream the output to an unencrypted file for use with the previewer. Or you can use the output as the input to a different encrypter (e.g. cloud file format).

How it works:

  • Create an instance of this class with the encryption key, and an input source for reading the cacheFile.
  • Then continually invoke the read:maxLength: method, passing in a buffer for the unencrypted data to be copied into.
  • This class will read and decrypt the next chuck of data from cacheFile source, and write the decrypted version to your buffer.
  • Creates an instance that will read from the given cryptoFile, decrypt the data, and produce the decrypted data to you via ‘read:maxLength:’.

    Declaration

    Objective-C

    - (instancetype)initWithCryptoFile:(ZDCCryptoFile *)cryptoFile;

    Swift

    init!(cryptoFile: ZDCCryptoFile!)

    Parameters

    cryptoFile

    An instance which contains the fileURL & encryptionKey. Also stream.retainToken is set to cryptoFile.retainToken.

  • Creates an instance that will read from the given cacheFileURL, decrypt the data, and produce the decrypted data to you via ‘read:maxLength:’.

    Declaration

    Objective-C

    - (instancetype)initWithCacheFileURL:(NSURL *)cacheFileURL
                           encryptionKey:(NSData *)encryptionKey;

    Swift

    init!(cacheFileURL: URL!, encryptionKey: Data!)

    Parameters

    cacheFileURL

    The location of the encrypted file in cache file format. The instance will open an inputStream with this URL in order to read the file.

    encryptionKey

    The key used to decrypt the file. (i.e. node.encryptionKey)

  • Creates an instance that will read from the given cacheFileStream, decrypt the data, and produce the decrypted data to you via ‘read:maxLength:’.

    Declaration

    Objective-C

    - (instancetype)initWithCacheFileStream:(NSInputStream *)cacheFileStream
                              encryptionKey:(NSData *)encryptionKey;

    Swift

    init!(cacheFileStream: InputStream!, encryptionKey: Data!)

    Parameters

    cacheFileStream

    A stream that can be used to read the encrypted file in cache file format.

    encryptionKey

    The key used to decrypt the file. (i.e. node.encryptionKey)

  • Creates an instance that will read from the given cacheFileData, decrypt the data, and produce the decrypted data to you via ‘read:maxLength:’.

    Note

    If your cacheFile data is in a file, don’t use this method. Instead you should be using initWithCacheFileURL::.

    Declaration

    Objective-C

    - (instancetype)initWithCacheFileData:(NSData *)cacheFileData
                            encryptionKey:(NSData *)encryptionKey;

    Swift

    init!(cacheFileData: Data!, encryptionKey: Data!)

    Parameters

    cacheFileData

    A smallish chunk of data. If your data is in a file, use initWithCacheFileURL:: instead.

    encryptionKey

    The key used to decrypt the file. (i.e. node.encryptionKey)

  • This value is anytime after the stream has been opened.

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSNumber *cleartextFileSize;

    Swift

    var cleartextFileSize: NSNumber! { get }