本文整理了Java中org.spongycastle.util.encoders.Base64.encode()
方法的一些代码示例,展示了Base64.encode()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Base64.encode()
方法的具体详情如下:
包路径:org.spongycastle.util.encoders.Base64
类名称:Base64
方法名:encode
[英]encode the input data producing a base 64 encoded byte array.
[中]对输入数据进行编码,生成一个基64编码字节数组。
代码示例来源:origin: ethereum/ethereumj
/**
*
* @return -
*/
public String toBase64() {
byte[] sigData = new byte[65]; // 1 header + 32 bytes for R + 32 bytes for S
sigData[0] = v;
System.arraycopy(bigIntegerToBytes(this.r, 32), 0, sigData, 1, 32);
System.arraycopy(bigIntegerToBytes(this.s, 32), 0, sigData, 33, 32);
return new String(Base64.encode(sigData), Charset.forName("UTF-8"));
}
代码示例来源:origin: com.madgag.spongycastle/core
/**
* encode the input data producing a base 64 encoded byte array.
*
* @return a byte array containing the base 64 encoded data.
*/
public static byte[] encode(
byte[] data)
{
return encode(data, 0, data.length);
}
代码示例来源:origin: OPCFoundation/UA-Java-Legacy
/** {@inheritDoc} */
@Override
public String base64Encode(byte[] bytes) {
try {
return new String(Base64.encode(bytes), "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: OPCFoundation/UA-Java-Legacy
/** {@inheritDoc} */
@Override
public String base64Encode(byte[] bytes) {
try {
return new String(Base64.encode(bytes), "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: OPCFoundation/UA-Java-Legacy
/**
* <p>base64Encode.</p>
*
* @param bytes an array of byte.
* @return a {@link java.lang.String} object.
*/
public static String base64Encode(byte[] bytes) {
try {
return new String(Base64.encode(bytes), "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: CoinbaseWallet/toshi-headless-client
public String encrypt(final String plainText, final String password) {
if (this.cipher == null) {
initWithPassword(password);
}
try {
cipher.init(Cipher.ENCRYPT_MODE, key, spec);
byte[] encrypted = cipher.doFinal(plainText.getBytes("UTF-8"));
return new String(Base64.encode(encrypted), "UTF-8");
} catch (InvalidKeyException | InvalidAlgorithmParameterException | IllegalBlockSizeException | BadPaddingException | UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: QuincySx/BlockchainWallet-Crypto
public static String encode(byte[] input) {
return Strings.fromByteArray(org.spongycastle.util.encoders.Base64.encode(input));
}
}
代码示例来源:origin: cternes/openkeepass
@Override
public String encrypt(String plainString) {
if (plainString == null) {
throw new IllegalArgumentException("PlainString must not be null");
}
try {
byte[] plainStringBytes = plainString.getBytes(ENCODING);
byte[] encodedText = new byte[plainStringBytes.length];
salsa20Engine.processBytes(plainStringBytes, 0, plainStringBytes.length, encodedText, 0);
byte[] protectedBuffer = Base64.encode(encodedText);
return new String(protectedBuffer, ENCODING);
} catch (UnsupportedEncodingException e) {
throw new UnsupportedOperationException(MSG_UNKNOWN_UTF8_ENCODING, e);
}
}
代码示例来源:origin: biheBlockChain/wkcwallet-java
/**
*
* @return -
*/
public String toBase64() {
byte[] sigData = new byte[65]; // 1 header + 32 bytes for R + 32
// bytes for S
sigData[0] = v;
System.arraycopy(bigIntegerToBytes(this.r, 32), 0, sigData, 1, 32);
System.arraycopy(bigIntegerToBytes(this.s, 32), 0, sigData, 33, 32);
return new String(Base64.encode(sigData), Charset.forName("UTF-8"));
}
代码示例来源:origin: nebulasio/neb.java
/**
*
* @return -
*/
public String toBase64() {
byte[] sigData = new byte[65]; // 1 header + 32 bytes for R + 32 bytes for S
sigData[0] = v;
System.arraycopy(ByteUtils.BigIntegerToBytes(this.r, 32), 0, sigData, 1, 32);
System.arraycopy(ByteUtils.BigIntegerToBytes(this.s, 32), 0, sigData, 33, 32);
return new String(Base64.encode(sigData), Charset.forName("UTF-8"));
}
代码示例来源:origin: AppStoreFoundation/asf-sdk
/**
* @return -
*/
public String toBase64() {
byte[] sigData = new byte[65]; // 1 header + 32 bytes for R + 32 bytes for S
sigData[0] = v;
System.arraycopy(bigIntegerToBytes(this.r, 32), 0, sigData, 1, 32);
System.arraycopy(bigIntegerToBytes(this.s, 32), 0, sigData, 33, 32);
return new String(Base64.encode(sigData), Charset.forName("UTF-8"));
}
代码示例来源:origin: tronprotocol/wallet-cli
/**
* @return -
*/
public String toBase64() {
byte[] sigData = new byte[65]; // 1 header + 32 bytes for R + 32
// bytes for S
sigData[0] = v;
System.arraycopy(bigIntegerToBytes(this.r, 32), 0, sigData, 1, 32);
System.arraycopy(bigIntegerToBytes(this.s, 32), 0, sigData, 33, 32);
return new String(Base64.encode(sigData), Charset.forName("UTF-8"));
}
代码示例来源:origin: yggdrash/yggdrash
/**
* @return -
*/
public String toBase64() {
byte[] sigData = new byte[65]; // 1 header + 32 bytes for R + 32 bytes for S
sigData[0] = v;
System.arraycopy(bigIntegerToBytes(this.r, 32), 0, sigData, 1, 32);
System.arraycopy(bigIntegerToBytes(this.s, 32), 0, sigData, 33, 32);
return new String(Base64.encode(sigData), Charset.forName("UTF-8"));
}
代码示例来源:origin: CoinbaseWallet/toshi-headless-client
/**
*
* @return -
*/
public String toBase64() {
byte[] sigData = new byte[65]; // 1 header + 32 bytes for R + 32 bytes for S
sigData[0] = v;
System.arraycopy(bigIntegerToBytes(this.r, 32), 0, sigData, 1, 32);
System.arraycopy(bigIntegerToBytes(this.s, 32), 0, sigData, 33, 32);
return new String(Base64.encode(sigData), Charset.forName("UTF-8"));
}
代码示例来源:origin: com.madgag.spongycastle/core
public static String toBase64String(
byte[] data,
int off,
int length)
{
byte[] encoded = encode(data, off, length);
return Strings.fromByteArray(encoded);
}
代码示例来源:origin: com.madgag/sc-light-jdk15on
private void writeEncoded(byte[] bytes)
throws IOException
{
bytes = Base64.encode(bytes);
for (int i = 0; i < bytes.length; i += buf.length)
{
int index = 0;
while (index != buf.length)
{
if ((i + index) >= bytes.length)
{
break;
}
buf[index] = (char)bytes[i + index];
index++;
}
this.write(buf, 0, index);
this.newLine();
}
}
代码示例来源:origin: com.madgag.spongycastle/core
private void writeEncoded(byte[] bytes)
throws IOException
{
bytes = Base64.encode(bytes);
for (int i = 0; i < bytes.length; i += buf.length)
{
int index = 0;
while (index != buf.length)
{
if ((i + index) >= bytes.length)
{
break;
}
buf[index] = (char)bytes[i + index];
index++;
}
this.write(buf, 0, index);
this.newLine();
}
}
代码示例来源:origin: yuger/VPN_2017
private void writeEncoded(byte[] bytes)
throws IOException
{
bytes = Base64.encode(bytes);
for (int i = 0; i < bytes.length; i += buf.length)
{
int index = 0;
while (index != buf.length)
{
if ((i + index) >= bytes.length)
{
break;
}
buf[index] = (char)bytes[i + index];
index++;
}
this.write(buf, 0, index);
this.newLine();
}
}
代码示例来源:origin: blockchain/unused-My-Wallet-V3-jar
@Test
public void testMagic() throws Exception {
String message = "{\"hello\":\"world\"}";
String expected1 = "LxR+2CipfgdIdi4EZgNOKTT+96WbppXnPZZjdZJ2vwA=";
String expected2 = "skkJOHg9L6/1OVztbUohjcvVR3cNdRDZ/OJOUdQI41M=";
byte[] magic = MetadataUtil.magic(message.getBytes(), null);
Assert.assertEquals(expected1, new String(Base64.encode(magic)));
byte[] nextMagic = MetadataUtil.magic(message.getBytes(), magic);
Assert.assertEquals(expected2, new String(Base64.encode(nextMagic)));
}
}
代码示例来源:origin: blockchain/unused-My-Wallet-V3-jar
@Test
public void testGetMessage() throws Exception {
String message = "{\"hello\":\"world\"}";
String expected1 = "eyJoZWxsbyI6IndvcmxkIn0=";
String expected2 = "LxR+2CipfgdIdi4EZgNOKTT+96WbppXnPZZjdZJ2vwCTojlxqRTl6svwqNJRVM2jCcPBxy+7mRTUfGDzy2gViA==";
byte[] result = MetadataUtil.message(message.getBytes("utf-8"), null);
Assert.assertEquals(expected1, new String(Base64.encode(result)));
byte[] magic = MetadataUtil.magic(message.getBytes(), null);
byte[] nextResult = MetadataUtil.message(message.getBytes(), magic);
Assert.assertEquals(expected2, new String(Base64.encode(nextResult)));
}
内容来源于网络,如有侵权,请联系作者删除!