Last Updated: February 25, 2016
·
1.474K
· _max_k

NSString SHA1 Verification

Quick and easy to implement NSString SHA1 verification tool to check to see if an NSString is a valid SHA1 has before sending over an unencrypted password to a server

- (BOOL) isSHA1:(NSString *) candidate;

- (BOOL) isSHA1:(NSString *)candidate {
    NSString *regex = @"^[a-f0-9]{40}$"; 
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex]; 
    return [predicate evaluateWithObject:candidate];
}