use of org.apache.commons.codec.binary.Base64.encodeBase64String in project candlepin by candlepin.
the class TestUtil method xmlToBase64String.
public static String xmlToBase64String(String xml) {
// byte[] bytes = Base64.encode(xml);
Base64 encoder = new Base64();
byte[] bytes = encoder.encode(xml.getBytes());
StringBuilder buf = new StringBuilder();
for (byte b : bytes) {
buf.append((char) Integer.parseInt(Integer.toHexString(b), 16));
}
return buf.toString();
}
use of org.apache.commons.codec.binary.Base64.encodeBase64String in project coastal-hazards by USGS-CIDA.
the class FileHelper method base64Encode.
/**
* Provides Base64 encoding and decoding as defined by <a
* href="http://tools.ietf.org/html/rfc2045">RFC 2045</a>.
*
* @param input
* @return Byte array representing the base 64 encoding of the incoming File
* or byte array
*/
public static byte[] base64Encode(final byte[] input) {
if (input == null) {
return (byte[]) Array.newInstance(byte.class, 0);
}
log.trace(new StringBuilder("Attempting to base64 encode a byte array of ").append(input.length).append(" bytes.").toString());
byte[] result = null;
Base64 encoder = new Base64();
result = encoder.encode(input);
return result;
}
use of org.apache.commons.codec.binary.Base64.encodeBase64String in project onebusaway-application-modules by camsys.
the class DigesterSignature method getDecodedValue.
public static String getDecodedValue(String key) {
Base64 coder = new Base64();
String encodedValue = key.substring(28);
byte[] rawInput = coder.decode(encodedValue.getBytes());
return new String(rawInput);
}
use of org.apache.commons.codec.binary.Base64.encodeBase64String in project ovirt-engine by oVirt.
the class EnvelopePBETest method test1.
@Test
public void test1() throws Exception {
Random random = new Random();
for (int i = 1; i < 100; i++) {
byte[] r = new byte[i];
random.nextBytes(r);
String password = new Base64(0).encodeToString(r);
String encoded = EnvelopePBE.encode("PBKDF2WithHmacSHA1", 256, 4000, null, password);
assertTrue(EnvelopePBE.check(encoded, password));
assertFalse(EnvelopePBE.check(encoded, password + "A"));
}
}
use of org.apache.commons.codec.binary.Base64.encodeBase64String in project ovirt-engine by oVirt.
the class SsoUtils method generateAuthorizationToken.
public static String generateAuthorizationToken() {
byte[] s = new byte[64];
secureRandom.nextBytes(s);
return new Base64(0, new byte[0], true).encodeToString(s);
}
Aggregations