我採取的是將iOS上運行的移動應用SHA-512功能的正常工作,此功能在所有的瀏覽器包括Safari工作正常。SHA-512不是IOS模擬器
我正在使用IOS模擬器測試我的應用程序。
我的應用程序在調用SHA-512的功能從一個網頁三次/點擊。問題是,首先調用sha-512函數會產生正確的結果,但在第二次和第三次調用時會產生錯誤的結果。
在此先感謝
我採取的是將iOS上運行的移動應用SHA-512功能的正常工作,此功能在所有的瀏覽器包括Safari工作正常。SHA-512不是IOS模擬器
我正在使用IOS模擬器測試我的應用程序。
我的應用程序在調用SHA-512的功能從一個網頁三次/點擊。問題是,首先調用sha-512函數會產生正確的結果,但在第二次和第三次調用時會產生錯誤的結果。
在此先感謝
這是我的代碼
//Creating Hash Value
NSString *hashkey = [NSString stringWithFormat:@"data"];
// PHP uses ASCII encoding, not UTF
NSLog(@"hashkey : %@",hashkey);
const char *s = [hashkey cStringUsingEncoding:NSASCIIStringEncoding];
NSData *keyData = [NSData dataWithBytes:s length:strlen(s)];
// This is the destination SHA512_Final
uint8_t digest[CC_SHA512_DIGEST_LENGTH] = {0};
// This one function does an unkeyed SHA1 hash of your hash data
CC_SHA512(keyData.bytes, keyData.length, digest);
// Now convert to NSData structure to make it usable again
NSData *out = [NSData dataWithBytes:digest length:CC_SHA512_DIGEST_LENGTH];
// description converts to hex but puts <> around it and spaces every 4 bytes
NSString *hash = [out description];
hash = [hash stringByReplacingOccurrencesOfString:@" " withString:@""];
hash = [hash stringByReplacingOccurrencesOfString:@"<" withString:@""];
hash = [hash stringByReplacingOccurrencesOfString:@">" withString:@""];
希望它可以幫助你..
我使用這個鏈接實現SHA512功能在javascript:http://jssha.sourceforge.net/好心使用JavaScript –
你爲什麼要使用JavaScript這個@vikaskumar幫我,蘋果已經擁有了SHA 512內置庫 –
我正在開發Web應用程序+移動Web應用程序,並使用sha512函數進行密碼驗證,還對下一級驗證的哈希值(二進制)執行一些XOR操作。此功能必須產生相同的輸出爲Web應用程序和移動Web應用程序... –
粘貼的,你已經嘗試什麼樣的代碼,我也使用SHA-512,但有從來沒有遇到這樣的問題 –