List of usage examples for org.apache.commons.codec.binary Base64 Base64
public Base64()
From source file:license.rsa.WakeRSA.java
public static void main(String[] args) throws Exception { System.out.println();/*from w w w . j av a2s . c o m*/ System.out.println("**********************md5**************************"); int len = md5(null).length; for (int i = 0; i < len; i++) { System.out.print(md5(null)[i]); } System.out.println(); System.out.println("**********************rsa**************************"); byte[] lmd5 = rsa(new Base64().decode(rsaStr)); for (int i = 0; i < lmd5.length; i++) { System.out.print(lmd5[i]); } }
From source file:com.amalto.workbench.utils.PasswordUtil.java
public static void main(String args[]) { Base64 base64 = new Base64(); String str = "qwe";//$NON-NLS-1$ byte[] enbytes = null; String encodeStr = null;// w w w . j a v a 2s .c om byte[] debytes = null; String decodeStr = null; enbytes = base64.encode(str.getBytes()); encodeStr = new String(enbytes); debytes = base64.decode(enbytes); decodeStr = new String(debytes); System.out.println("plain password:" + str); //$NON-NLS-1$ System.out.println("encrypted password:" + encodeStr); //$NON-NLS-1$ System.out.println("decrypted password:" + decodeStr); //$NON-NLS-1$ }
From source file:BrokerFrame.java
/** * @param args the command line arguments *//*from w ww .j ava 2s . co m*/ public static void main(String args[]) throws Exception { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(BrokerFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(BrokerFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(BrokerFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(BrokerFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> String ola = new String(); ola = "olajjhgjhhjkhjkhjhkjhjhgg"; RSA rs = new RSA(); rs.generateKeys(); System.out.println((RSA.privKey).toString()); byte[] signature = rs.encrypt(ola, RSA.privKey); String sig = new Base64().encodeAsString(signature); byte[] byt = new Base64().decode(sig); System.out.println(sig); try { rs.verifySignature(ola.getBytes(), signature); } catch (Exception e) { throw new Exception(e); } /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new BrokerFrame().setVisible(true); } }); }
From source file:Main.java
public static PrivateKey getPrivateKey(String key) { try {// www. j ava 2 s.co m Base64 base64_decoder = new Base64(); byte[] byteKey = base64_decoder.decode(key.getBytes()); // , // Base64.DEFAULT); PKCS8EncodedKeySpec X509privateKey = new PKCS8EncodedKeySpec(byteKey); KeyFactory kf = KeyFactory.getInstance("RSA"); return kf.generatePrivate(X509privateKey); } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:br.com.aws.odonto.utils.CryptoApacheCodec.java
/** * Codifica string na base 64 (Encoder)//ww w . j av a 2s. c o m */ public static String codificaBase64Encoder(String msg) { return new Base64().encodeToString(msg.getBytes()); }
From source file:br.com.aws.odonto.utils.CryptoApacheCodec.java
/** * Decodifica string na base 64 (Decoder) *///from ww w. j a v a 2s. co m public static String decodificaBase64Decoder(String msg) { return new String(new Base64().decode(msg)); }
From source file:com.burkeware.search.api.util.ResolverUtil.java
public static String getBasicAuth(final String username, final String password) { String auth = username + ":" + password; return "Basic " + new String(new Base64().encode(auth.getBytes())); }
From source file:com.ddling.utils.MyBase64.java
public static String decodeStr(String str) { Base64 base64 = new Base64(); byte[] debytes = base64.decodeBase64(new String(str).getBytes()); return new String(debytes); }
From source file:Main.java
public static PublicKey getPublicKey(String key) { try {/*from www . jav a2 s .c om*/ Base64 base64_decoder = new Base64(); byte[] byteKey = base64_decoder.decode(key.getBytes()); // , // Base64.DEFAULT); X509EncodedKeySpec X509publicKey = new X509EncodedKeySpec(byteKey); KeyFactory kf = KeyFactory.getInstance("RSA"); return kf.generatePublic(X509publicKey); } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:com.ddling.client.utils.MyBase64.java
/** * Base64?/*w w w . j av a 2 s. co m*/ * @param str ?? * @return ?? */ public static String decodeStr(String str) { Base64 base64 = new Base64(); byte[] debytes = base64.decodeBase64(new String(str).getBytes()); return new String(debytes); }