List of usage examples for org.apache.commons.codec.binary Base64 encodeBase64
public static byte[] encodeBase64(final byte[] binaryData, final boolean isChunked, final boolean urlSafe, final int maxResultSize)
From source file:com.revolucion.secretwit.stego.URLSteganography.java
public static String encode(String text) { try {/*from w w w. j a v a2s . com*/ return new String(Base64.encodeBase64(text.getBytes(DEFAULT_CHARSET), false, true, 10)); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return null; }
From source file:core.SHA256Hash.java
public static String CalculateCheckSumBase64(String FileName, String url) throws Exception { MessageDigest md = MessageDigest.getInstance(SHA256); FileInputStream fileHandle = new FileInputStream(FileName); byte[] dataBytes = new byte[1024]; int nread = 0; while ((nread = fileHandle.read(dataBytes)) != -1) { md.update(dataBytes, 0, nread);/* www.j a v a2 s .c om*/ } ; byte[] mdbytes = md.digest(); byte[] bytes = null; if (SHA256 == getHashAlgType(url)) { // Do base64 encoding bytes = Base64.encodeBase64URLSafe(mdbytes); } else { if (SHA256_16 == getHashAlgType(url)) bytes = Base64.encodeBase64(new byte[] { mdbytes[0], mdbytes[1] }, false, true, 4); } // Store byte array as string and return it String value = new String(bytes); System.out.println("Base64 encoded " + getHashAlgType(url) + " hash: " + value); return value; }