2013-01-18 47 views
0

可能重複:
iPhone/OS X LION: How to retrieve the decoded data from the CC_SHA256 encrypted data?解碼SHA256目標C

我使用這endoce我的字符串。我如何解碼它?

-(NSString*)sha256HashFor:(NSString*)input 
{ 
    const char* str = [input UTF8String]; 
    unsigned char result[CC_SHA256_DIGEST_LENGTH]; 
    CC_SHA256(str, strlen(str), result); 

    NSMutableString *ret = [NSMutableString stringWithCapacity:CC_SHA256_DIGEST_LENGTH*2]; 
    for(int i = 0; i<CC_SHA256_DIGEST_LENGTH; i++) 
    { 
     [ret appendFormat:@"%02x",result[i]]; 
    } 
    return ret; 
} 
+1

您不能解碼哈希,這是一種點的。 – mttrb

+0

http://stackoverflow.com/questions/10174536/iphone-os-x-lion-how-to-retrieve-the-decoded-data-from-the-cc-sha256-encrypted – JaredH

回答

3

SHA(安全散列算法)是一個數字的加密散列函數中的一個。加密散列就像是文本或數據文件的簽名。 SHA-256算法生成幾乎唯一的固定大小的256位(32字節)散列。 哈希是一種單向函數 - 它不能被解密。這使它適用於密碼驗證,挑戰散列驗證,防篡改,數字簽名。

希望這個信息可以幫助你..