我正在实现 AES 解码器,用于创建 IV 和密钥,算法是这样的
IV Key的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;
}
但我没有得到正确的结果。我的填充方法是否正确。请帮忙