Guest User

Untitled

a guest
Jan 22nd, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. /** Generates a 128 bits cryptographically secure key, formatted as a UUID.
  2. * Keep that you won't have the same guarantee for uniqueness
  3. * as you have with regular UUIDs.
  4. * @return A cryptographically secure UUID.
  5. */
  6. + (NSString*)generateCryptoSecureUUID
  7. {
  8. unsigned char bytes[16];
  9. int result = SecRandomCopyBytes(kSecRandomDefault, 16, bytes);
  10. if (result != noErr) {
  11. return nil;
  12. }
  13. return [[NSUUID alloc] initWithUUIDBytes:bytes].UUIDString;
  14. }
Add Comment
Please, Sign In to add comment