-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterface.java
More file actions
92 lines (73 loc) · 2.96 KB
/
Interface.java
File metadata and controls
92 lines (73 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package pB.view;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
/*
* @author Renan Roseno
*/
public class Interface extends JFrame {
private JLabel lbTitulo;
private JPasswordField pfSenha;
private JButton btCodificar;
private JLabel foto;
private JLabel lbNome;
private Font letra;
public Interface(){
inicializarComponentes();
definirEventos();
}
public void inicializarComponentes(){
lbTitulo = new JLabel("SENHA");
pfSenha = new JPasswordField();
btCodificar = new JButton("CODIFICAR");
lbNome = new JLabel("<> PASSWORD CRIPTO");
letra = new Font("Courier New",Font.BOLD,20);
lbNome.setFont(letra);
lbNome.setBounds(20, 5, 280, 30);
lbTitulo.setBounds(120,50,50,80);
pfSenha.setBounds(50,120,180,30);
btCodificar.setBounds(90,170,100,30);
add(lbTitulo);
add(pfSenha);
add(lbNome);
add(btCodificar);
}
public void definirEventos(){
btCodificar.addActionListener( new ActionListener(){
@Override
public void actionPerformed(ActionEvent ae) {
String a[] ={"X","a" , "b", "c", "d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z",
"0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q",
"R","S","T","U","V","X","Y","Z","X"};
String teste = new String(pfSenha.getPassword());
int i =0;
int p = 0;
String r = teste;
String c[] = null;
dispose();
try{
MessageDigest md = MessageDigest.getInstance("SHA-256");
byte messageDigest[] = md.digest(r.getBytes("UTF-8"));
StringBuilder sb = new StringBuilder();
for(byte b: messageDigest){
sb.append(String.format("%02X", 0xFF & b));
}
String senhaHex = sb.toString();
JOptionPane.showMessageDialog(null," \nSua senha codificada é : " + senhaHex + "\nSua senha é: "+ teste );
dispose();
}catch(Exception e){
}
}
});
}
}