我有下面的 ObjC 方法,我想将它移植到托管代码,但不知道从哪里开始。有人可以帮忙吗?
- (NSData *)deriveKey
{
NSData *passphrase = [self.passwordField.stringValue dataUsingEncoding:NSUTF8StringEncoding];
NSData *salt = [self.saltField.stringValue dataUsingEncoding:NSUTF8StringEncoding];
NSMutableData *key = [NSMutableData dataWithLength:kCCKeySizeAES256];
CCKeyDerivationPBKDF(kCCPBKDF2,
[passphrase bytes],
[passphrase length],
[salt bytes],
[salt length],
kCCPRFHmacAlgSHA256,
PBKDFNumberOfRounds,
[key mutableBytes],
[key length]);
return key;
}