本文整理了Java中net.iharder.Base64.encodeBytes()
方法的一些代码示例,展示了Base64.encodeBytes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Base64.encodeBytes()
方法的具体详情如下:
包路径:net.iharder.Base64
类名称:Base64
方法名:encodeBytes
[英]Encodes a byte array into Base64 notation. Does not GZip-compress data.
[中]将字节数组编码为Base64表示法。不压缩数据。
代码示例来源:origin: igniterealtime/Smack
@Override
public String encodeToString(byte[] input, int offset, int len) {
return Base64.encodeBytes(input, offset, len);
}
代码示例来源:origin: briandilley/jsonrpc4j
@Test
public void testGetMethod_base64Params() throws Exception {
EasyMock.expect(mockService.testMethod("Whir?inaki")).andReturn("For?est");
EasyMock.replay(mockService);
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/test-get");
MockHttpServletResponse response = new MockHttpServletResponse();
request.addParameter("id", Integer.toString(123));
request.addParameter("method", "testMethod");
request.addParameter("params", net.iharder.Base64.encodeBytes("[\"Whir?inaki\"]".getBytes(StandardCharsets.UTF_8)));
jsonRpcServer.handle(request, response);
assertTrue("application/json-rpc".equals(response.getContentType()));
checkSuccessfulResponse(response);
}
代码示例来源:origin: fgp/AirReceiver
/**
* Encodes data to Base64 and padds with "="
*
* @param data data to encode
* @return base64 encoded string
*/
public static String encodePadded(final byte[] data)
{
return net.iharder.Base64.encodeBytes(data);
}
代码示例来源:origin: pwm-project/pwm
public static String base64Encode( final byte[] input )
{
return Base64.encodeBytes( input );
}
代码示例来源:origin: uk.org.mygrid.taverna/taverna-contrib
/**
* Encodes a byte array into Base64 notation. Does not GZip-compress data.
*
* @param source
* The data to convert
* @since 1.4
*/
public static String encodeBytes(byte[] source) {
return encodeBytes(source, 0, source.length, NO_OPTIONS);
} // end encodeBytes
代码示例来源:origin: briandilley/jsonrpc4j
@Test
public void testGetMethod_badRequest_noMethod() throws Exception {
EasyMock.expect(mockService.testMethod("Whirinaki")).andReturn("Forest");
EasyMock.replay(mockService);
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/test-get");
MockHttpServletResponse response = new MockHttpServletResponse();
request.addParameter("id", Integer.toString(123));
// no method!
request.addParameter("params", net.iharder.Base64.encodeBytes("[\"Whirinaki\"]".getBytes(StandardCharsets.UTF_8)));
jsonRpcServer.handle(request, response);
assertTrue(MockHttpServletResponse.SC_NOT_FOUND == response.getStatus());
JsonNode errorNode = error(toByteArrayOutputStream(response.getContentAsByteArray()));
assertNotNull(errorNode);
assertEquals(errorCode(errorNode).asLong(), (long) ErrorResolver.JsonError.METHOD_NOT_FOUND.code);
}
代码示例来源:origin: uk.org.mygrid.taverna/taverna-contrib
/**
* Encodes a String into Base64 notation.
*
* @param source
* @return
*/
public static String encodeString(String source) {
return encodeBytes(source.getBytes());
}
代码示例来源:origin: NGDATA/lilyproject
public static String valueToString(byte[] value) {
// URL safe encoding because the value (= the blob access key) might be embedded in URIs
try {
return Base64.encodeBytes(value, Base64.URL_SAFE);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: com.ngdata/hbase-indexer-model
private void setByteArrayProperty(ObjectNode node, String property, byte[] data) {
if (data == null)
return;
try {
node.put(property, Base64.encodeBytes(data, Base64.GZIP));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: NGDATA/hbase-indexer
private void setByteArrayProperty(ObjectNode node, String property, byte[] data) {
if (data == null)
return;
try {
node.put(property, Base64.encodeBytes(data, Base64.GZIP));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: com.jamesmurty.utils/java-xmlbuilder
/**
* Add a CDATA node with Base64-encoded byte data content to the element
* for this builder node.
*
* @param data
* the data value that will be Base64-encoded and added to a CDATA element.
*/
protected void cdataImpl(byte[] data) {
xmlNode.appendChild(
getDocument().createCDATASection(
Base64.encodeBytes(data)));
}
代码示例来源:origin: io.syndesis.common/common-util
private static String encodeKey(byte[] data) throws SyndesisServerException {
try {
return "i" + Base64.encodeBytes(data, 2, 15, Base64.ORDERED) + "z";
} catch (final IOException e) {
throw new SyndesisServerException(e);
}
}
代码示例来源:origin: pelotoncycle/weberknecht
private String createNonce()
{
byte[] nonce = new byte[16];
for (int i = 0; i < 16; i++) {
nonce[i] = (byte) rand(0, 255);
}
return Base64.encodeBytes(nonce);
}
代码示例来源:origin: com.xeiam.xchange/xchange-bitfinex
@Override
public synchronized String digestParams(RestInvocation restInvocation) {
String postBody = restInvocation.getRequestBody();
return Base64.encodeBytes(postBody.getBytes());
}
}
代码示例来源:origin: Nextdoor/bender
/**
* Add a CDATA node with Base64-encoded byte data content to the element
* for this builder node.
*
* @param data
* the data value that will be Base64-encoded and added to a CDATA element.
*/
protected void cdataImpl(byte[] data) {
xmlNode.appendChild(
getDocument().createCDATASection(
Base64.encodeBytes(data)));
}
代码示例来源:origin: jmurty/java-xmlbuilder
/**
* Add a CDATA node with Base64-encoded byte data content to the element
* for this builder node.
*
* @param data
* the data value that will be Base64-encoded and added to a CDATA element.
*/
protected void cdataImpl(byte[] data) {
xmlNode.appendChild(
getDocument().createCDATASection(
Base64.encodeBytes(data)));
}
代码示例来源:origin: com.xeiam.xchange/xchange-bitfinex
@Override
public String digestParams(RestInvocation restInvocation) {
String postBody = restInvocation.getRequestBody();
Mac mac = getMac();
mac.update(Base64.encodeBytes(postBody.getBytes()).getBytes());
return String.format("%096x", new BigInteger(1, mac.doFinal()));
}
}
代码示例来源:origin: com.xeiam.xchange/xchange-bitcurex
@Override
public String digestParams(RestInvocation restInvocation) {
String digest;
byte[] signature;
Mac sha512 = getMac();
sha512.update(restInvocation.getRequestBody().getBytes());
signature = sha512.doFinal();
digest = Base64.encodeBytes(signature);
return digest;
}
}
代码示例来源:origin: com.xeiam.xchange/xchange-loyalbit
@Override
public String digestParams(RestInvocation restInvocation) {
Mac mac256 = getMac();
mac256.update(restInvocation.getInvocationUrl().getBytes());
mac256.update(restInvocation.getParamValue(FormParam.class, "nonce").toString().getBytes());
mac256.update(clientId.getBytes());
mac256.update(apiKey);
return Base64.encodeBytes(mac256.doFinal());
}
}
代码示例来源:origin: com.xeiam.xchange/xchange-anx
@Override
public String digestParams(RestInvocation restInvocation) {
Mac mac = getMac();
mac.update(restInvocation.getMethodPath().getBytes());
mac.update(new byte[] { 0 });
mac.update(restInvocation.getRequestBody().getBytes());
return Base64.encodeBytes(mac.doFinal()).trim();
}
}
内容来源于网络,如有侵权,请联系作者删除!