List of usage examples for org.apache.commons.codec.binary Base64 decodeBase64
public static byte[] decodeBase64(final byte[] base64Data)
From source file:de.scrubstudios.srvmon.notificator.classes.Crypt.java
public static String decrypt(String key, String data) { byte[] decryptedData = null; SecretKeySpec keySpec = new SecretKeySpec(key.getBytes(), "AES"); try {/*from w w w . j av a2 s.com*/ Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); cipher.init(Cipher.DECRYPT_MODE, keySpec); //decryptedData = cipher.doFinal(Base64.decode(data)); decryptedData = cipher.doFinal(Base64.decodeBase64(data)); //return new String(decryptedData); return new String(decryptedData); } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | IllegalBlockSizeException | BadPaddingException ex) { Logger.getLogger(Crypt.class.getName()).log(Level.SEVERE, null, ex); } return null; }
From source file:com.microsoftopentechnologies.auth.jwt.JWTParser.java
/** * Absolutely basic, bare minimum implementation of JWT parsing as needed * for parsing the ID token returned by Azure Active Directory as * documented here - https://msdn.microsoft.com/en-us/library/azure/dn645542.aspx. * * @param jwtInput The ID token JWT string. * @return The JWT object representing the information encoded in the JWT. * @throws ParseException/*from w ww . ja v a 2 s . c o m*/ */ public static JWT parse(String jwtInput) throws ParseException { if (Strings.isNullOrEmpty(jwtInput)) { throw new ParseException("jwt string is null/empty.", 0); } // split the period delimited string List<String> tokens = Splitter.on('.').omitEmptyStrings().splitToList(jwtInput); // the length of the list MUST be 2 or more if (tokens.size() < 2) { throw new ParseException("Invalid JWT string supplied.", 0); } // parse JWT header and claims JsonParser jsonParser = new JsonParser(); JsonObject header = (JsonObject) jsonParser.parse(stringFromBase64(tokens.get(0))); JsonObject claims = (JsonObject) jsonParser.parse(new String(Base64.decodeBase64(tokens.get(1)))); return JWT.parse(header, claims); }
From source file:com.splicemachine.derby.stream.output.PipelineWriterBuilder.java
public static PipelineWriterBuilder getHTableWriterBuilderFromBase64String(String base64String) throws IOException { if (base64String == null) throw new IOException("tableScanner base64 String is null"); return (PipelineWriterBuilder) SerializationUtils.deserialize(Base64.decodeBase64(base64String)); }
From source file:com.shigengyu.hyperion.core.WorkflowContextBinarySerializer.java
@Override public <T extends WorkflowContext> T deserialize(final Class<T> clazz, String input) { Object workflowContext = null; try {/* ww w . jav a2s . c o m*/ workflowContext = SerializationUtils.deserialize(Base64.decodeBase64(input)); if (workflowContext == null) { return null; } return clazz.cast(workflowContext); } catch (ClassCastException e) { if (workflowContext != null) { throw new WorkflowContextException("Unable to cast workflow context of type [" + workflowContext.getClass().getName() + "] to [" + clazz.getName() + "]"); } else { throw new WorkflowContextException(e); } } }
From source file:com.itemanalysis.jmetrik.workspace.JmetrikPassword.java
public String decodePassword(String pw) { byte[] decode = Base64.decodeBase64(pw); String decodeString = StringUtils.newStringUtf8(decode); return decodeString; }
From source file:com.formatAdmin.utils.UtilsSecurity.java
public static String decifrarMD5(String textoEncriptado) throws Exception { String base64EncryptedString = ""; try {// ww w. j a v a 2 s . com byte[] message = Base64.decodeBase64(textoEncriptado.getBytes("utf-8")); MessageDigest md = MessageDigest.getInstance("MD5"); byte[] digestOfPassword = md.digest(SECRET_MD5_KEY.getBytes("utf-8")); byte[] keyBytes = Arrays.copyOf(digestOfPassword, 24); SecretKey key = new SecretKeySpec(keyBytes, ENCRYPT_ALGORITHM); Cipher decipher = Cipher.getInstance(ENCRYPT_ALGORITHM); decipher.init(Cipher.DECRYPT_MODE, key); byte[] plainText = decipher.doFinal(message); base64EncryptedString = new String(plainText, "UTF-8"); } catch (UnsupportedEncodingException | InvalidKeyException | NoSuchAlgorithmException | BadPaddingException | IllegalBlockSizeException | NoSuchPaddingException ex) { throw ex; } return base64EncryptedString; }
From source file:ab.server.proxy.message.ProxyScreenshotMessage.java
@Override public byte[] gotResponse(JSONObject data) { String imageStr = (String) data.get("data"); imageStr = imageStr.split(",", 2)[1]; byte[] imageBytes = Base64.decodeBase64(imageStr); return imageBytes; }
From source file:com.juicioenlinea.application.secutiry.Security.java
public static String desencriptar(String textoEncriptado) { final String secretKey = "hunter"; //llave para encriptar datos String encryptedString = null; try {//from w ww .ja va 2 s . c o m byte[] message = Base64.decodeBase64(textoEncriptado.getBytes("UTF-8")); MessageDigest md = MessageDigest.getInstance("SHA"); byte[] digestOfPassword = md.digest(secretKey.getBytes("UTF-8")); byte[] keyBytes = Arrays.copyOf(digestOfPassword, 24); SecretKey key = new SecretKeySpec(keyBytes, "DESede"); Cipher decipher = Cipher.getInstance("DESede"); decipher.init(Cipher.DECRYPT_MODE, key); byte[] plainText = decipher.doFinal(message); encryptedString = new String(plainText, "UTF-8"); } catch (UnsupportedEncodingException | InvalidKeyException | NoSuchAlgorithmException | NoSuchPaddingException | IllegalBlockSizeException | BadPaddingException ex) { Logger.getLogger(Security.class.getName()).log(Level.SEVERE, null, ex); } return encryptedString; }
From source file:minium.cucumber.report.domain.JsonBase64Deserializer.java
@Override public byte[] deserialize(JsonParser jsonParser, DeserializationContext context) throws IOException, JsonProcessingException { String value = jsonParser.getValueAsString(); return Base64.decodeBase64(value); }
From source file:com.mnr.java.intellij.idea.plugin.base64helper.HexDecoderPopupItem.java
@Override public String encodeDecode(String selectedText) { return Hex.encodeHexString(Base64.decodeBase64(selectedText)).toUpperCase(); }