我正在处理JS脚本(ru,该脚本会上传一个应用以进行协调。 当我尝试提交应用程序内容文件以进行调优时,我总是会收到commitFileFailed,但我看不到任何原因。有什么办法可以弄清楚为什么会失败?
我认为可能是因为加密,但是我不确定。这是我加密的方式:
const key = Crypto.randomBytes(32);
const hmacKey = Crypto.randomBytes(32);
const iv = Crypto.randomBytes(16);
const cipher = Crypto.createCipheriv('aes256', key, iv);
const hmac = Crypto.createHmac('sha256', hmacKey);
const hash = Crypto.createHash('sha256');
let encrypted = cipher.update(originalFileBuffer);
encrypted = [...encrypted, ...cipher.final()];
const encryptedBuffer = Buffer.from(encrypted);
let encryptedHmac = hmac.update(encryptedBuffer);
let digest = hmac.digest('base64');
hash.update(Buffer.from(originalFileBuffer));
const fileDigest = hash.digest('base64');
const encryptionInfo = {
fileEncryptionInfo: {
'@odata.type': 'microsoft.graph.fileEncryptionInfo',
encryptionKey: Buffer.from(key).toString('base64'),
macKey: Buffer.from(hmacKey).toString('base64'),
initializationVector: Buffer.from(iv).toString('base64'),
mac: digest,
profileIdentifier: 'ProfileVersion1',
fileDigest: fileDigest,
fileDigestAlgorithm: 'SHA256'
}
};
我的加密信息如下:
{
"encryptionKey": "5hYywG3rkdeMLSuvW6xyvA==",
"macKey": "0PVu0l0avph6p2E3HCpHIw==",
"initializationVector": "UQVtvxe4n28oWrMLz5ei9w==",
"mac": "hjD5yZnOPFJjgijB4vtdw+6Lh8U3X2Xnp8dOcscv/QI=",
"profileIdentifier": "ProfileVersion1",
"fileDigest": "wMlT8MU7Rm0BXzIj8STRCjjye/Hn0UQTqQ9A2eRb41U=",
"fileDigestAlgorithm": "SHA256"
}
清单是这样的
<?xml version="1.0" encoding="utf-8"?>
<AndroidManifestProperties xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Package>test.android.app</Package>
<PackageVersionCode>1</PackageVersionCode>
<PackageVersionName>1.0.0</PackageVersionName>
<ApplicationName>TestApp.apk</ApplicationName>
<MinSdkVersion>4</MinSdkVersion>
<AWTVersion/>
</AndroidManifestProperties>
任何帮助将不胜感激。谢谢。