List of usage examples for org.apache.commons.codec.binary Base64 encodeBase64URLSafeString
public static String encodeBase64URLSafeString(final byte[] binaryData)
From source file:com.cliqset.magicsig.util.KeyTester.java
public static void main(String[] args) { try {/*w w w . j av a 2 s .c o m*/ FileInputStream fis = new FileInputStream(keyFile); BufferedReader reader = new BufferedReader(new InputStreamReader(fis)); String line = null; while ((line = reader.readLine()) != null) { MagicKey key = new MagicKey(line.getBytes("ASCII")); RSASHA256MagicSigAlgorithm alg = new RSASHA256MagicSigAlgorithm(); byte[] sig = alg.sign(data, key); System.out.println(Base64.encodeBase64URLSafeString(sig)); boolean verified = alg.verify(data, sig, key); if (!verified) { System.out.println("FAILED - " + line); } //System.out.println(lineSplit[0] + " " + key.toString(true)); } } catch (Exception e) { e.printStackTrace(); } System.out.println("Done."); }
From source file:mobisocial.nfcserver.DesktopNfcServer.java
public static void main(String[] args) { try {/*w w w.j a v a 2s. co m*/ Contract server; if (args.length > 0 && args[0].equals("tcp")) { // recoverable failure; if args is null, length == 0. server = new TcpNdefServer(args); } else if (args.length > 0 && args[0].equals("junction")) { server = new JunctionNdefServer(args); } else { server = new BluetoothNdefServer(args); //Builder<BluetoothNdefServer>().build(); } String content = ConnectionHandoverManager.USER_HANDOVER_PREFIX + Base64.encodeBase64URLSafeString(getHandoverNdef(server.getHandoverUrl()).toByteArray()); System.out.println("Welcome to DesktopNfc!"); System.out.println("Service running on " + server.getHandoverUrl()); System.out.println("Your configuration QR is: " + QR.getQrl(content)); // QRL server.start(); NfcInterface nfc = getInstance(); final String PROMPT = "> "; BufferedReader lineReader = new BufferedReader(new InputStreamReader(System.in)); while (true) { System.out.print(PROMPT); String line = lineReader.readLine().trim(); nfc.share(line); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.networknt.light.util.HashUtil.java
public static String generateUUID() { UUID id = UUID.randomUUID(); ByteBuffer bb = ByteBuffer.wrap(new byte[16]); bb.putLong(id.getMostSignificantBits()); bb.putLong(id.getLeastSignificantBits()); Base64 base64 = new Base64(); return base64.encodeBase64URLSafeString(bb.array()); }
From source file:com.microsoft.applicationinsights.extensibility.initializer.SequencePropertyInitializer.java
private static String uuidToBase64() { Base64 base64 = new Base64(); UUID uuid = UUID.randomUUID(); ByteBuffer bb = ByteBuffer.wrap(new byte[16]); bb.putLong(uuid.getMostSignificantBits()); bb.putLong(uuid.getLeastSignificantBits()); return base64.encodeBase64URLSafeString(bb.array()); }
From source file:com.creditcloud.common.taglib.Functions.java
public static String base64(String value) { return Base64.encodeBase64URLSafeString(value.getBytes()); }
From source file:com.hengyi.japp.tools.UuidUtils.java
protected static String base64Uuid(UUID uuid) { ByteBuffer bb = ByteBuffer.wrap(new byte[16]); bb.putLong(uuid.getMostSignificantBits()); bb.putLong(uuid.getLeastSignificantBits()); return Base64.encodeBase64URLSafeString(bb.array()); }
From source file:com.fruit.core.util.MyDigestUtils.java
public static String encode64(String str) { try {/* w w w . j a v a2 s . com*/ return Base64.encodeBase64URLSafeString(str.getBytes("utf-8")); } catch (UnsupportedEncodingException e) { } return Base64.encodeBase64URLSafeString(str.getBytes()); }
From source file:com.scf.utils.UUIDUtilies.java
protected static String base64Uuid(UUID uuid) { ByteBuffer bb = ByteBuffer.wrap(new byte[16]); bb.putLong(uuid.getMostSignificantBits()); bb.putLong(uuid.getLeastSignificantBits()); return Base64.encodeBase64URLSafeString(bb.array()); }
From source file:at.supp.JsonTokenUtil2.java
public static String convertToBase64(String source) { return Base64.encodeBase64URLSafeString(StringUtils.getBytesUtf8(source)); }
From source file:com.easemob.dataexport.utils.CodecUtils.java
public static String base64(String str) { return Base64.encodeBase64URLSafeString(bytes(str)); }