DroidScript / Docs

DroidScript Documentation
Apache License 2.0
80 stars 29 forks source link

Criptografia no play #183

Open MfixCode opened 1 month ago

MfixCode commented 1 month ago

Não está passando a criptografia cifra inseguro

Al4He6 commented 1 month ago

Translates from Portuguese as Not passing encryption encryption encryption insecure Not sure if the reporter is referring to app.CreateCrypt or obfuscation in the builder, or ...

MfixCode commented 1 month ago

Tirei o obfuscate e mesmo assim não passou. Realmente eu uso app.createcrypt(). Se puder me orientar, porque só falta isso pra passar. Este é o código.

function generateIV() { var array = new Uint8Array(12); window.crypto.getRandomValues(array); return array; }

function encryptText(plainText, key) { const crypt = app.CreateCrypt(); const iv = generateIV(); const encryptedData = crypt.Encrypt(plainText, key, "AES/GCM/NoPadding", iv);

return JSON.stringify({
    iv: Array.from(iv).map(byte => String.fromCharCode(byte)).join(''),  // Converte o IV para string
    encryptedData: btoa(encryptedData) // Converte dados criptografados para Base64
});

}

function decryptText(encryptedText, key) { const encryptedDataObj = JSON.parse(encryptedText); const iv = new Uint8Array(encryptedDataObj.iv.split('').map(char => char.charCodeAt(0))); const crypt = app.CreateCrypt(); const decodedData = atob(encryptedDataObj.encryptedData); // Decodifica os dados de Base64 const decryptedText = crypt.Decrypt(decodedData, key, "AES/GCM/NoPadding", iv);

return decryptedText;

}