mirror of
https://github.com/aljazceru/cyphernode.git
synced 2025-12-27 01:25:49 +01:00
24 lines
478 B
JavaScript
24 lines
478 B
JavaScript
const exec = require('child_process').exec;
|
|
|
|
module.exports = async ( password ) => {
|
|
|
|
if( !password ) {
|
|
return null;
|
|
}
|
|
|
|
password = password.replace(/'/g, `'\\''`);
|
|
|
|
return await new Promise( (resolve) => {
|
|
exec('htpasswd -bnB admin \''+password+'\' | cut -sd \':\' -f2', (error, stdout, stderr) => {
|
|
if (error) {
|
|
return resolve(null);
|
|
}
|
|
// remove newline at the end
|
|
resolve(stdout.substr(0,stdout.length-1));
|
|
});
|
|
});
|
|
|
|
|
|
};
|
|
|