List of usage examples for org.apache.commons.codec.binary Base64 decodeBase64
public static byte[] decodeBase64(final byte[] base64Data)
From source file:com.streamsets.pipeline.lib.el.Base64EL.java
@ElFunction(prefix = "base64", name = "decodeString", description = "Returns a decoded string from a base64 encoded string argument and charset name.") public static String base64Decode(@ElParam("string") String encoded, @ElParam("charset") String charset) throws UnsupportedEncodingException { return new String(Base64.decodeBase64(encoded), Charset.forName(charset)); }
From source file:com.imaginary.home.cloud.Configuration.java
static public @Nonnull String decrypt(@Nonnull String keySalt, @Nonnull String value) { try {/*from ww w . j av a 2s . c o m*/ SecretKeySpec spec = new SecretKeySpec(getConfiguration().getCustomSalt(keySalt), "AES"); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.DECRYPT_MODE, spec); byte[] b64 = value.getBytes("utf-8"); byte[] raw = Base64.decodeBase64(b64); byte[] decrypted = cipher.doFinal(raw); return new String(decrypted, "utf-8"); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:io.jsonwebtoken.impl.Base64Codec.java
@Override public byte[] decode(String encoded) { //return javax.xml.bind.DatatypeConverter.parseBase64Binary(encoded); return Base64.decodeBase64(encoded); }
From source file:com.alu.e3.prov.restapi.util.Base64Adapter.java
public String unmarshal(String s) { if (s == null) return null; return new String(Base64.decodeBase64(s)); }
From source file:com.orange.mmp.crypto.CipherBase64Impl.java
public byte[] decode() throws CipheringException { return Base64.decodeBase64(this.content); }
From source file:com.ro.ssc.app.client.licensing.TrialKeyValidator.java
public static String decodeKey(String encodedEncrypted) { String decoded = ""; try {// w ww . j a v a2s. c o m byte[] saltDecrypt = SALT_DECRYPT.getBytes(StandardCharsets.UTF_8); SecretKeyFactory factoryKeyDecrypt = SecretKeyFactory.getInstance(SECRET_KEY_FACTORY); SecretKey tmp2 = factoryKeyDecrypt.generateSecret( new PBEKeySpec(PASS_DECRYPT.toCharArray(), saltDecrypt, ITERATIONS_DECRYPT, KEY_LENGTH)); SecretKeySpec decryptKey = new SecretKeySpec(tmp2.getEncoded(), ALGORITHM); Cipher aesCipherDecrypt = Cipher.getInstance(CIPHER); aesCipherDecrypt.init(Cipher.DECRYPT_MODE, decryptKey); byte[] e64bytes = StringUtils.getBytesUtf8(encodedEncrypted); byte[] eBytes = Base64.decodeBase64(e64bytes); byte[] cipherDecode = aesCipherDecrypt.doFinal(eBytes); decoded = StringUtils.newStringUtf8(cipherDecode); } catch (Exception e) { LOGGER.error("Error while decoding the trial key", e); } return decoded; }
From source file:hudson.util.Protector.java
/** * Returns null if fails to decrypt properly. */// w w w .j a v a 2 s. c om public static String unprotect(String data) { if (data == null) { return null; } try { Cipher cipher = Secret.getCipher(ALGORITHM); cipher.init(Cipher.DECRYPT_MODE, DES_KEY); String plainText = new String(cipher.doFinal(Base64.decodeBase64(data)), "UTF-8"); if (plainText.endsWith(MAGIC)) { return plainText.substring(0, plainText.length() - 3); } return null; } catch (GeneralSecurityException e) { return null; } catch (UnsupportedEncodingException e) { throw new Error(e); // impossible } catch (IOException e) { return null; } }
From source file:com.microsoft.azure.iothub.auth.SignatureHelper.java
/** * Decodes the deviceKey using Base64.// w w w. j a va2 s .co m * * @param deviceKey the device key. * * @return the Base64-decoded device key. */ public static byte[] decodeDeviceKeyBase64(String deviceKey) { // Codes_SRS_SIGNATUREHELPER_11_003: [The function shall decode the device key using Base64.] return Base64.decodeBase64(deviceKey.getBytes()); }
From source file:de.fhdo.helper.DES.java
public static String decrypt(String Text) { try {/*www . ja v a 2 s .c o m*/ DESKeySpec keySpec = new DESKeySpec("schluessel_stdrepository15".getBytes("UTF8")); SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES"); SecretKey key = keyFactory.generateSecret(keySpec); byte[] encrypedPwdBytes = Base64.decodeBase64(Text); Cipher cipher = Cipher.getInstance("DES");// cipher is not thread safe cipher.init(Cipher.DECRYPT_MODE, key); byte[] plainTextPwdBytes = (cipher.doFinal(encrypedPwdBytes)); return new String(plainTextPwdBytes); } catch (Exception e) { e.printStackTrace(); } return ""; }
From source file:net.enilink.komma.em.internal.ByteArrayConverter.java
@Override public byte[] deserialize(String label) { return Base64.decodeBase64(label.getBytes()); }