0
我正好是獲得變化的輸出,當我調用摘要方法(在Java)和CC_SHA1(在Objective-C多次。SHA1輸出循環內變化
請注意,當環未被使用,我得到匹配輸出。
以下是我目前使用的實現。
目標C片段
NSString *haha= [NSString stringWithFormat:@"%@%@",sPassPhrase,sSaltValue];
NSData *abKey0 = [haha dataUsingEncoding:NSASCIIStringEncoding];
NSMutableData *abKey = [NSMutableData dataWithData:abKey0];
unsigned char digest[20];
for(int i=1;i<iIterations;i++)
{
CC_SHA1(abKey.bytes, abKey.length, digest);
abKey = [NSMutableData dataWithBytes:digest length:20];
}
Java片段
String haha = sPassPhrase + sSaltValue;
byte[] abKey = haha.getBytes("US-ASCII");
MessageDigest oSHA1 = MessageDigest.getInstance("SHA-1");
for (int i = 1; i <= iIterations; i++)
{
abKey = oSHA1.digest(abKey);
}
這讓我搜索api文檔幾個小時了,但是我找不到任何有用的東西。
嘿嘿...這是一個很好的接收! – ipmcc
感謝您的回答。正如您已經很清楚地注意到的那樣。不要再爲我自己尷尬了,我會接受你的回答。 – Leena
@Leena:不需要感到尷尬,我們有*所有*曾經在那裏,很多次。 –