当前位置:   article > 正文

java hmac sha512_HMACSHA512

java hmacsha512

- (NSString *)generate:(NSString *)secretKey {

NSString *counter = @"1527866554";

NSData *counterBytes = [counter dataUsingEncoding:NSUTF8StringEncoding];

NSData *keyBytes = [secretKey dataUsingEncoding:NSUTF8StringEncoding];

NSMutableData *macOut = [NSMutableData dataWithLength:CC_SHA512_DIGEST_LENGTH];

CCHmac( kCCHmacAlgSHA512,

keyBytes.bytes,

keyBytes.length,

counterBytes.bytes,

counterBytes.length,

macOut.mutableBytes);

unsigned long long hash = 0;

[macOut getBytes:&hash length:sizeof(unsigned long)];

unsigned long long token = hash % (unsigned long)pow(10, 15);

NSString *strToken = [NSString stringWithFormat:@"%015lld", token];

NSLog(@"secret key = %@, counter = %@, payment code = %@", secretKey, counter, strToken);

return strToken;

}

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/730823
推荐阅读
相关标签
  

闽ICP备14008679号