0

IVとキーを作成するために、AESデコーダーを実装しています。アルゴリズムは次のようになります

IVキーの16バイト:ProductID.getBytes("UTF-8")の最初の16バイト

            (If there are no enough bytes,      

            make up to 16 bytes at right by 0x32)   

パディングのための私のコード

- (char*)paddedStringFromString:(NSString *)string withLength:(NSUInteger)length{
    const char *stringC = [string UTF8String];
    char * output;
    output = malloc(length+1);
    for (NSInteger i = 0; i < length; i++) {
        if (i < string.length) output[i] = stringC[i];
        else output[i] = 0x32;
    }
    return output;
}

しかし、私は正しい結果を得ていません。パディングに対する私のアプローチは正しいですか。助けてください

4

1 に答える 1

0

引数の長さとstring.lengthは同じではないと思いますよね?

于 2012-10-16T04:04:57.773 に答える