Locksmith icon indicating copy to clipboard operation
Locksmith copied to clipboard

Writing & Reading String data to/from keychain

Open daveluong opened this issue 8 years ago • 0 comments

Hi,

We're currently in the process of migrating to Swift. Our existing keychain management library SAMKeychain (SSKeychain) is writing & saving String data to keychain. I'd like to ask how do we go about making Locksmith compatible with SSKeychain in this sense? (we're trying to avoid writing data migration code)

SSKeychain

- (NSString *)password {
    if ([self.passwordData length]) {
        return [[NSString alloc] initWithData:self.passwordData encoding:NSUTF8StringEncoding];
    }
    return nil;
}

Locksmith

public extension CreateableSecureStorable where Self : InternetPasswordSecureStorable {
    var asCreateableSecureStoragePropertyDictionary: [String: Any] {
        var old = internetPasswordBaseStoragePropertyDictionary
        old[String(kSecValueData)] = NSKeyedArchiver.archivedData(withRootObject: data)
        return old
    }
}

Is there away to override the above variable to return different dictionary where the value is NSData of a string instead of the data dictionary?

daveluong avatar Sep 22 '16 03:09 daveluong