Mediante una clave secreta, ciframos un mensaje y después podemos descrifrar el mensaje con la misma clave u otra distinta. De esta forma hay dos tipos de algoritmos, según cantidad de claves:
- Critografía simétrica
- Criptografía asimétrica
private Lock cerrojo = new ReentrantLock();
dialog.addWindowListener(new WindowAdapter(){
publicvoid windowClosing(WindowEvent we){
cerrojo.lock();
desconectando = true;
cerrojo.unlock();
}
});
Aquí tenéis la documentación: Enlace.
import java.io.FileInputStream;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class MD5 {
public static String getMD5(String entrada) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] messageDigest = md.digest(entrada.getBytes());
BigInteger number = new BigInteger(1, messageDigest);
String hashtext = number.toString(16);
while (hashtext.length() < 32) {
hashtext = "0" + hashtext;
}
return hashtext;
}
catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
public static void main(String[] args) throws NoSuchAlgorithmException {
System.out.println(getMD5("Nuestra Clave"));
}
}
private JButton boton = new JButton("Botón");
boton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
System.out.println("Click!");
}
});
Aquí tenéis la documentación: Enlace
shell = new Shell(SWT.DIALOG_TRIM | SWT.MIN);
frame.setResizable(false);
SWT.BORDER SWT.CLOSE SWT.MIN SWT.MAX SWT.RESIZE SWT.TITLE SWT.NO_TRIM SWT.SHELL_TRIM SWT.DIALOG_TRIM SWT.MODELESS SWT.PRIMARY_MODAL SWT.APPLICATION_MODAL SWT.SYSTEM_MODAL
public class NavegadorEmbebidoSWT extends Composite {
private Browser browser;
ProgressBar progressBar;
boolean busy;
int index;
public NavegadorEmbebidoSWT(Composite parent, String urlEntorno) {
super(parent, SWT.NONE);
GridLayout layout = new GridLayout(2, true);
setLayout(layout);
browser = new Browser(this, SWT.NONE);
GridData layoutData = new GridData(GridData.FILL_BOTH);
layoutData.horizontalSpan = 2;
layoutData.verticalSpan = 2;
browser.setLayoutData(layoutData);
//Barra de progreso
progressBar = new ProgressBar(this, SWT.NONE);
progressBar.setLocation(600, 5);
progressBar.setSize(108, 23);
browser.addProgressListener(new ProgressListener() {
public void changed(ProgressEvent event) {
if (event.total == 0)
return;
int ratio = event.current * 100 / event.total;
if (progressBar != null)
progressBar.setSelection(ratio);
busy = event.current != event.total;
if (!busy) {
index = 0;
}
}
public void completed(ProgressEvent event) {
if (progressBar != null)
progressBar.setSelection(0);
busy = false;
index = 0;
}
});
browser.setUrl(urlEntorno);
}
}
exception in thread main java.lang.noclassdeffounderror