gpt4 book ai didi

iphone - 解密 AES128 加密的数据

转载 作者:行者123 更新时间:2023-12-03 20:58:23 28 4
gpt4 key购买 nike

我正在尝试解密最近几天的数据。我解密了数据,但结果与原始结果不同。请任何人都可以建议我如何做到这一点。我正在尝试解密以下数据:

加密数据:“Mmb9tEkmW82oFPJb3vNhHA==”

加密 key :“91860F52E5C3A09BA3B827F28070E08D”

原始数据:“Marco”

请帮忙。谢谢

最佳答案

这是我如何使用 AES128

- (NSData *)cipherData:(NSData *)data {
return [self aesOperation:kCCEncrypt OnData:data];
}

- (NSData *)decipherData:(NSData *)data {
return [self aesOperation:kCCDecrypt OnData:data];
}


- (NSData *)aesOperation:(CCOperation)op OnData:(NSData *)data {
NSData *outData = nil;

// Data in parameters
const void *key = cipherKey.bytes;
const void *dataIn = data.bytes;
size_t dataInLength = data.length;
// Data out parameters
size_t outMoved = 0;

// Init out buffer
unsigned char outBuffer[BUFFER_SIZE];
memset(outBuffer, 0, BUFFER_SIZE);
CCCryptorStatus status = -1;

status = CCCrypt(op, kCCAlgorithmAES128, kCCOptionPKCS7Padding, key, kCCKeySizeAES256, NULL,
dataIn, dataInLength, &outBuffer, BUFFER_SIZE, &outMoved);

if(status == kCCSuccess) {
outData = [NSData dataWithBytes:outBuffer length:outMoved];
} else if(status == kCCBufferTooSmall) {
// Resize the out buffer
size_t newsSize = outMoved;
void *dynOutBuffer = malloc(newsSize);
memset(dynOutBuffer, 0, newsSize);
outMoved = 0;

status = CCCrypt(op, kCCAlgorithmAES128, kCCOptionPKCS7Padding, key, kCCKeySizeAES256, NULL,
dataIn, dataInLength, &outBuffer, BUFFER_SIZE, &outMoved);

if(status == kCCSuccess) {
outData = [NSData dataWithBytes:outBuffer length:outMoved];
}
}

return outData;
}

关于iphone - 解密 AES128 加密的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3192451/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com