EncFS array paths

This commit is contained in:
Jiang Yio 2022-10-01 07:37:14 -04:00
parent 3beb008969
commit 7c0e1bfbcf

View File

@ -279,11 +279,13 @@ EncFS.fromPassword = async function(fs, password) {
return String.fromCharCode.apply(null, new Uint8Array(res));
}
async function path_encrypt(data) {
return (await Promise.all(data.split('/').map(x => path_component_encrypt(x)))).join('/');
if((data) && (data.constructor === Array)) return await Promise.all(data.map(x => path_component_encrypt(x)));
else return (await Promise.all(data.split('/').map(x => path_component_encrypt(x)))).join('/');
}
async function path_decrypt(data) {
if(data.startsWith('/')) return '/' + await path_decrypt(data.replace(/^\/+/g, ''));
return (await Promise.all(data.split('/').map(x => path_component_decrypt(x)))).join('/');
if((data) && (data.constructor === Array)) return await Promise.all(data.map(x => path_component_decrypt(x)));
else if(data.startsWith('/')) return '/' + await path_decrypt(data.replace(/^\/+/g, ''));
else return (await Promise.all(data.split('/').map(x => path_component_decrypt(x)))).join('/');
}
return new EncFS((await fs.mkdir('ZZZE ' + uint8array_to_b64(new Uint8Array(await digest('SHA-1', password))))).chroot(), data_encrypt, data_decrypt, path_encrypt, path_decrypt);
};