I have the following code in Java:
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
public class EnconderPass {
public static void main(String[] args) {
String password = "12345";
byte[] newPassword = null;
try {
newPassword = MessageDigest.getInstance("SHA").digest(password.getBytes("UTF-8"));
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String encriptado = Base64.getEncoder().encodeToString(newPassword);
System.out.println(encriptado);
}
}
I want to reproduce the same results with Python 3, but I do not know how to "translate" it. In this Java example the string 1235 is equivalent to jLIjfQZ5yojbZGTqxg2pY0VROWQ =
How could I do it in Python 3?