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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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 CommonCryptoinstead 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: