I'm try to set a user password and executing the system.setPassword(UserId, Password) method and I always get an error saying that the UserId is invalid. I've checked it and it's the correct UserId. Example: System.setPassword('email@example.com','test');
I hope you're not hard coding passwords, here's a few lines to generate a random alphanumeric char. Use as you will.
final String selectionString = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; Integer idNum = Math.mod(Math.abs(Crypto.getRandomInteger()), selectionString.length()); String randomChar = selectionString.substring(idNum, idNum+1);