List of usage examples for org.apache.commons.codec.binary Base64 decodeBase64
public static byte[] decodeBase64(final byte[] base64Data)
From source file:com.baidu.terminator.plugin.signer.customized.app.Base64ForServer.java
/** * 64??byte/*from w ww .j ava2 s . c om*/ * Decode Base64 String into Byte Array * * @param str ?64 * @return ??byte * @throws UnsupportedEncodingException ???UTF-8? */ public static byte[] base64toByte(String str) throws UnsupportedEncodingException { if (str == null) throw new IllegalArgumentException("The parameter should not be null!"); return Base64.decodeBase64(str.getBytes("UTF-8")); }
From source file:com.app.framework.listeners.ApplicationListener.java
@Override public void contextInitialized(ServletContextEvent sce) { System.out.println("Hello. Application Started."); System.out.println("Working Dir: " + Application.getWorkingDir().getAbsolutePath()); String s = new String("mcg"); System.out.println("" + s); String md5 = MD5Utils.md5(s); System.out.println(md5);/*from ww w . j ava 2s . c o m*/ SecretKey key = AESUtils.generateSecretKey(); byte[] keyBytes = AESUtils.getKeyBytes(key); key = AESUtils.getSecretKey(keyBytes); String encrypted = null; try { encrypted = Base64.encodeBase64String(AESUtils.encrypt(md5, key)); byte[] decrypted = AESUtils.decrypt(Base64.decodeBase64(encrypted.getBytes("utf-8")), key); System.out.println(encrypted); System.out.println(new String(decrypted)); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } }
From source file:com.ibm.ra.remy.web.utils.RestUtils.java
/** * Method to Base 64 decode a string./*from w w w .j a va 2s. c o m*/ * * @param data The string to decode. * @return The decoded string. */ public String base64Decode(String data) { return new String(Base64.decodeBase64(data)); }
From source file:D_common.E_ncript.java
public static String decryptString(String strToDecrypt, String keyStr) { try {//from w w w. j a va2s .c o m String ret = new String(decrypt(Base64.decodeBase64(strToDecrypt), keyStr), "UTF-8"); return ret; } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:com.moss.bdbadmin.api.util.KeyFactory.java
public static byte[] decode(String urlEncodedKey) { try {/* w w w . j a v a2 s . c o m*/ String utfBase64 = URLDecoder.decode(urlEncodedKey, ENCODING); byte[] base64 = utfBase64.getBytes(ENCODING); byte[] key = Base64.decodeBase64(base64); return key; } catch (Exception ex) { throw new RuntimeException(ex); } }
From source file:edu.wpi.cs.wpisuitetng.authentication.BasicAuth.java
@Override protected String[] parsePost(String post) throws AuthenticationException { // format: ["Authorization:", "Basic", Base64-encoded credentials] String[] parts = post.split(" "); if (!isValidBasicAuth(parts)) { logger.log(Level.WARNING, "Login attempted with invalid BasicAuth token"); throw new AuthenticationException( "The <" + this.getAuthType() + "> authentication token is invalid format"); }/* w w w. j a va2 s. c om*/ byte[] decoded = Base64.decodeBase64(parts[1]); String[] credentials = (new String(decoded)).split(":"); // split decoded token username:password // check if the credential array has space for username and password elements. if (credentials.length != 2) { logger.log(Level.WARNING, "Login attempted with invalid BasicAuth token"); throw new AuthenticationException( "The <" + this.getAuthType() + "> token's encoded portion is missing a piece"); } return credentials; }
From source file:edu.vt.middleware.ldap.LdapUtil.java
/** * This will decode the supplied value as a base64 encoded string to a byte[]. * * @param value to base64 decode//from w w w .j a va2s . c om * * @return base64 decoded value */ public static byte[] base64Decode(final String value) { return value != null ? Base64.decodeBase64(value.getBytes()) : null; }
From source file:com.droitfintech.licensing.ObfuscatedLicenseProvider.java
public License decodeObfuscatedLicense(String obfuscated) { String plaintext;//from w w w .j a v a2s .c om try { plaintext = new String(Base64.decodeBase64(obfuscated), "UTF-8"); logger.debug(plaintext); ObjectMapper mapper = new ObjectMapper(); return mapper.readValue(plaintext, License.class); } catch (Exception e) { throw new DroitException("Unable to deserialize '" + obfuscated + "'", e); } }
From source file:cl.niclabs.tscrypto.common.datatypes.BigIntegerBase64TypeAdapter.java
@Override public BigInteger deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { return new BigInteger(Base64.decodeBase64(json.getAsString())); }
From source file:net.mooncloud.hadoop.hive.ql.udf.UDFUnbase64.java
public BytesWritable evaluate(Text value) { if (value == null) { return null; }//w w w . ja v a2 s . co m byte[] bytes = new byte[value.getLength()]; System.arraycopy(value.getBytes(), 0, bytes, 0, value.getLength()); byte[] decoded = Base64.decodeBase64(bytes); result.set(decoded, 0, decoded.length); return result; }