forked from Blendman974/faceclaw
Porting onboarding/flashing flow io iOS
This commit is contained in:
1 parent
68b459751e
commit
64bf600ef9
46 files changed
+1419
-211
No files matched your search
@@ -1,4 +1,5 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
@interface FaceclawCrypto : NSObject
|
||||
+ (NSString *)hmacSha256:(NSString *)secret message:(NSString *)message;
|
||||
+ (NSString *)sha256:(NSData *)data;
|
||||
@end
|
||||
@@ -9,4 +9,11 @@
|
||||
CCHmac(kCCHmacAlgSHA256, key.bytes, key.length, data.bytes, data.length, digest);
|
||||
return [[NSData dataWithBytes:digest length:sizeof(digest)] base64EncodedStringWithOptions:0];
|
||||
}
|
||||
+ (NSString *)sha256:(NSData *)data {
|
||||
unsigned char digest[CC_SHA256_DIGEST_LENGTH];
|
||||
CC_SHA256(data.bytes, (CC_LONG)data.length, digest);
|
||||
NSMutableString *hex = [NSMutableString stringWithCapacity:64];
|
||||
for (NSUInteger i = 0; i < sizeof(digest); i++) [hex appendFormat:@"%02x", digest[i]];
|
||||
return hex;
|
||||
}
|
||||
@end
|
||||
Reference in new issue
Block a user