car in 場站查車鎖車 ios
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
631B

  1. //
  2. // Util.m
  3. // goodpk
  4. //
  5. // Created by 歐特儀 on 2020/6/19.
  6. // Copyright © 2020 Altob. All rights reserved.
  7. //
  8. #import "Util.h"
  9. #include <CommonCrypto/CommonDigest.h>
  10. @implementation Util
  11. +(NSString*)sha256HashFor:(NSString*)input
  12. {
  13. const char* str = [input UTF8String];
  14. unsigned char result[CC_SHA256_DIGEST_LENGTH];
  15. CC_SHA256(str, strlen(str), result);
  16. NSMutableString *ret = [NSMutableString stringWithCapacity:CC_SHA256_DIGEST_LENGTH*2];
  17. for(int i = 0; i<CC_SHA256_DIGEST_LENGTH; i++)
  18. {
  19. [ret appendFormat:@"%02x",result[i]];
  20. }
  21. return [ret substringToIndex:10];
  22. }
  23. @end