加密解密 - iOS中hmac_sha1如何解密
迷茫
迷茫 2017-04-17 15:15:09
0
1
865

加密方法如下

- (NSString *)HmacSha1WithSecret:(NSString *)key
{

    const char *cKey  = [key cStringUsingEncoding:NSASCIIStringEncoding];
    const char *cData = [self cStringUsingEncoding:NSASCIIStringEncoding];

    unsigned char cHMAC[CC_SHA1_DIGEST_LENGTH];

    CCHmac(kCCHmacAlgSHA1, cKey, strlen(cKey), cData, strlen(cData), cHMAC);

    NSData *HMAC = [[NSData alloc] initWithBytes:cHMAC length:sizeof(cHMAC)];

    NSString *hash = [QNUrlSafeBase64 encodeData:HMAC];
    return hash;
}
迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(1)
伊谢尔伦

MD5, SHA-1, SHA-224, SHA-256, SHA-384, SHA-512, and their corresponding HMAC algorithms are all hash algorithms, also called digest algorithms, one-way operations, irreversible, so There is no way to decrypt it. However, it can be cracked through brute force (generating strings one by one in order), which of course will take a very long time, and the result of this test may not be the original result, because there are indeed multiple source data that can calculate the same hash value. column results.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template