I found where the hashPassword function is, so using it is as simple as this:
const auth = require("@strapi/admin/server/services/auth");
async function generateRandomPassword() {
let pass = '';
const str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' +
'abcdefghijklmnopqrstuvwxyz' +
'0123456789' +
'@#$%?!<>';
for (let i = 1; i <= 16; i++) {
const char = Math.floor(Math.random() * str.length + 1);
pass += str.charAt(char)
}
return await auth.hashPassword(pass);
}
@JonasJW this avoid something in your solution that I find to be an issue: replicating code from Strapi that they might change in the future.