Notes
Here's an example of how to set a user's password in Apex:
try {
User u = [SELECT Id FROM User WHERE Username = 'user@example.com' LIMIT 1];
String newPassword = 'A$tr0ngPW';
// Set the new password
System.setPassword(u.Id, newPassword);
System.debug('Password successfully updated for user: ' + u.Username);
} catch (DmlException e) {
System.debug('Error setting password: ' + e.getMessage());
}