How can I create a SHA1 from a NSString
.
Let's say the NSString is set up as:
NSString *message = @"Message";
I can use PHP to create a SHA1 hash with sha($message)
. But unfortunately it doesn't work like that within Objective-C.
How can I create a SHA1 from a NSString
.
Let's say the NSString is set up as:
NSString *message = @"Message";
I can use PHP to create a SHA1 hash with sha($message)
. But unfortunately it doesn't work like that within Objective-C.
I have this in a category on NSString (available at https://github.com/hypercrypt/NSString-Hashes):
Starting with Xcode 10.0, you should use
import CommonCrypto
instead since it is now natively available in Swift! If you have recently migrated to Xcode 10.0 and use the old approach, this can be your cue to make the change: