Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. import java.io.UnsupportedEncodingException;
  2. import java.security.MessageDigest;
  3. import java.security.NoSuchAlgorithmException;
  4. import java.util.Base64;
  5.  
  6. public class EnconderPass {
  7.  
  8. public static void main(String[] args) {
  9. String password = "12345";
  10. byte[] newPassword = null;
  11. try {
  12. newPassword = MessageDigest.getInstance("SHA").digest(password.getBytes("UTF-8"));
  13. } catch (NoSuchAlgorithmException e) {
  14. // TODO Auto-generated catch block
  15. e.printStackTrace();
  16. } catch (UnsupportedEncodingException e) {
  17. // TODO Auto-generated catch block
  18. e.printStackTrace();
  19. }
  20.  
  21.  
  22. String encriptado = Base64.getEncoder().encodeToString(newPassword);
  23. System.out.println(encriptado);
  24.  
  25. }
  26.  
  27. }
  28.  
  29. import hashlib
  30. import base64
  31.  
  32.  
  33. KEY = "12345".encode()
  34. digest = hashlib.sha1(KEY).digest()
  35. string = base64.b64encode(digest).decode('UTF-8')
  36. print(string)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement