List of usage examples for org.apache.commons.codec.binary Hex encodeHexString
public static String encodeHexString(byte[] data)
From source file:com.netscape.cmstools.pkcs12.PKCS12CertCLI.java
public static void printCertInfo(PKCS12 pkcs12, PKCS12CertInfo certInfo) throws Exception { byte[] id = certInfo.getID(); System.out.println(" Certificate ID: " + Hex.encodeHexString(id)); System.out.println(" Serial Number: " + new CertId(certInfo.getCert().getSerialNumber()).toHexString()); System.out.println(" Friendly Name: " + certInfo.getFriendlyName()); System.out.println(" Subject DN: " + certInfo.getCert().getSubjectDN()); System.out.println(" Issuer DN: " + certInfo.getCert().getIssuerDN()); if (certInfo.getTrustFlags() != null) { System.out.println(" Trust Flags: " + certInfo.getTrustFlags()); }/*from www. j a va 2 s . c o m*/ System.out.println(" Has Key: " + (pkcs12.getKeyInfoByID(id) != null)); }
From source file:Crypto.java
/** * adding main() for usage demonstration. With member vars, some of the locals would not be needed *///from ww w .j av a 2s . co m public static void main(String[] args) { // create the input.txt file in the current directory before continuing File input = new File("input.txt"); File eoutput = new File("encrypted.aes"); File doutput = new File("decrypted.txt"); String iv = null; String salt = null; Crypto en = new Crypto("mypassword"); /* * setup encryption cipher using password. print out iv and salt */ try { en.setupEncrypt(); iv = Hex.encodeHexString(en.getInitVec()).toUpperCase(); salt = Hex.encodeHexString(en.getSalt()).toUpperCase(); } catch (InvalidKeyException e) { e.printStackTrace(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (InvalidKeySpecException e) { e.printStackTrace(); } catch (NoSuchPaddingException e) { e.printStackTrace(); } catch (InvalidParameterSpecException e) { e.printStackTrace(); } catch (IllegalBlockSizeException e) { e.printStackTrace(); } catch (BadPaddingException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } /* * write out encrypted file */ try { en.WriteEncryptedFile(input, eoutput); System.out.printf("File encrypted to " + eoutput.getName() + "\niv:" + iv + "\nsalt:" + salt + "\n\n"); } catch (IllegalBlockSizeException e) { e.printStackTrace(); } catch (BadPaddingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } /* * decrypt file */ Crypto dc = new Crypto("mypassword"); try { dc.setupDecrypt(iv, salt); } catch (InvalidKeyException e) { e.printStackTrace(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (InvalidKeySpecException e) { e.printStackTrace(); } catch (NoSuchPaddingException e) { e.printStackTrace(); } catch (InvalidAlgorithmParameterException e) { e.printStackTrace(); } catch (DecoderException e) { e.printStackTrace(); } /* * write out decrypted file */ try { dc.ReadEncryptedFile(eoutput, doutput); System.out.println("decryption finished to " + doutput.getName()); } catch (IllegalBlockSizeException e) { e.printStackTrace(); } catch (BadPaddingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.amazon.janusgraph.diskstorage.dynamodb.builder.AbstractBuilder.java
public static String encodeKeyBuffer(StaticBuffer input) { if (input == null || input.length() == 0) { return null; }/*from w ww . j av a2 s . c o m*/ ByteBuffer buf = input.asByteBuffer(); byte[] bytes = Arrays.copyOf(buf.array(), buf.limit()); return Hex.encodeHexString(bytes); }
From source file:com.arrow.acn.client.utils.MD5Util.java
public static String calcMD5ChecksumString(Path path) throws NoSuchAlgorithmException, IOException { return Hex.encodeHexString(calcMD5Checksum(path)); }
From source file:com.kuzumeji.platform.standard.SecurityHelperTest.java
@Test public void testDigest() { final byte[] message = "?????????????".getBytes(); final byte[] digest = SecurityHelper.digest(message); assertThat(Hex.encodeHexString(digest), is( "ffd0ed718ee77320095dfaa71217525a3d1ada061f14635904cf2c10bcc6c36932ee9a8b513f902e8a4b277c2e6c1e408a6077b0c0d774fa283faafa0138a7ff")); }
From source file:com.ait.tooling.server.core.security.SimpleHexSignatoryEncoder.java
@Override public String encodeBytes(final byte[] src) throws Exception { return Hex.encodeHexString(src); }
From source file:com.ngdata.hbaseindexer.uniquekey.HexUniqueKeyFormatter.java
@Override protected String encodeAsString(byte[] bytes) { return Hex.encodeHexString(bytes); }
From source file:com.floreantpos.util.PasswordHasher.java
public static String hashPassword(String password) { byte[] passwordBytes = null; MessageDigest md = null;/*from w ww . j ava2 s . c o m*/ try { passwordBytes = password.getBytes("UTF-8"); //$NON-NLS-1$ } catch (UnsupportedEncodingException e) { PosLog.error(PasswordHasher.class, e.getMessage()); } try { md = MessageDigest.getInstance("SHA1"); //$NON-NLS-1$ } catch (NoSuchAlgorithmException e) { PosLog.error(PasswordHasher.class, e.getMessage()); } byte[] hashBytes = md.digest(passwordBytes); return Hex.encodeHexString(hashBytes); }
From source file:monasca.persister.repository.Sha1HashId.java
@Override public String toString() { return "Sha1HashId{" + "sha1Hash=" + Hex.encodeHexString(sha1Hash) + "}"; }
From source file:com.arrow.acn.client.utils.MD5Util.java
public static String calcMD5ChecksumString(File file) throws NoSuchAlgorithmException, IOException { return Hex.encodeHexString(calcMD5Checksum(file)); }