net.i2p.data.Base64.encode()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(105)

本文整理了Java中net.i2p.data.Base64.encode()方法的一些代码示例,展示了Base64.encode()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Base64.encode()方法的具体详情如下:
包路径:net.i2p.data.Base64
类名称:Base64
方法名:encode

Base64.encode介绍

[英]Output will be a multiple of 4 chars, including 0-2 trailing '=' As of 0.9.14, encodes the UTF-8 encoding of source. Prior to that, used the platform's encoding.
[中]

代码示例

代码示例来源:origin: i2p/i2p.i2p

/**
 *  Output will be a multiple of 4 chars, including 0-2 trailing '='
 *  @param source if null will return ""
 */
public static String encode(byte[] source, int off, int len) {
  return (source != null ? encode(source, off, len, false) : "");
}

代码示例来源:origin: i2p/i2p.i2p

@Override
public String toBase64() {
  if (_data == null)
    return null;
  return Base64.encode(_data);
}

代码示例来源:origin: i2p/i2p.i2p

/**
 *  Output will be a multiple of 4 chars, including 0-2 trailing '='
 *  @param source if null will return ""
 *  @param useStandardAlphabet Warning, must be false for I2P compatibility
 */
public static String encode(byte[] source, boolean useStandardAlphabet) {
  return (source != null ? encode(source, 0, source.length, useStandardAlphabet) : "");
}

代码示例来源:origin: i2p/i2p.i2p

/**
 *  Output will be a multiple of 4 chars, including 0-2 trailing '='
 *  @param source if null will return ""
 */
public static String encode(byte[] source) {
  return (source != null ? encode(source, 0, source.length) : "");
}

代码示例来源:origin: i2p/i2p.i2p

public final String toBase64() {
    return Base64.encode(_data, _offset, _valid);
  }
}

代码示例来源:origin: i2p/i2p.i2p

public void toRawString(StringBuilder buf) {
  if (_message != null)
    buf.append(Base64.encode(_message, _payloadBeginOffset, _payloadLength));
}

代码示例来源:origin: i2p/i2p.i2p

public String toBase64() {
  byte data[] = toByteArray();
  if (data == null)
    return null;
  return Base64.encode(data);
}

代码示例来源:origin: i2p/i2p.i2p

public Introducer(byte[] ip, int port, byte[] key, long tag) {
  sip = Addresses.toString(ip);
  sport = String.valueOf(port);
  skey = Base64.encode(key);
  stag = String.valueOf(tag);
}

代码示例来源:origin: i2p/i2p.i2p

/**
 *  Output will be a multiple of 4 chars, including 0-2 trailing '='
 *  As of 0.9.14, encodes the UTF-8 encoding of source. Prior to that, used the platform's encoding.
 *
 *  @param source if null will return ""
 */
public static String encode(String source) {
  return (source != null ? encode(DataHelper.getUTF8(source)) : "");
}

代码示例来源:origin: i2p/i2p.i2p

/**
 *  Remove the magnet marker from the config file.
 *  @since 0.8.4
 */
public void removeMagnetStatus(byte[] ih) {
  String infohash = Base64.encode(ih);
  infohash = infohash.replace('=', '$');
  if (_config.remove(PROP_META_MAGNET_PREFIX + infohash) != null)
    saveConfig();
}

代码示例来源:origin: i2p/i2p.i2p

private static void encode(InputStream in, OutputStream out) throws IOException {
  String encoded = encode(read(in));
  for (int i = 0; i < encoded.length(); i++)
    out.write((byte)(encoded.charAt(i) & 0xFF));
}

代码示例来源:origin: i2p/i2p.i2p

public void readAliceIntroKey(byte target[], int targetOffset) {
  int offset = readBodyOffset() + 4;
  offset += _message[offset] & 0xff;
  offset += 1 + 2;
  int sz = _message[offset] & 0xff;
  offset++;
  offset += sz;
  System.arraycopy(_message, offset, target, targetOffset, SessionKey.KEYSIZE_BYTES);
  if (_log.shouldLog(Log.DEBUG))
    _log.debug("read alice intro key: " + Base64.encode(target, targetOffset, SessionKey.KEYSIZE_BYTES)
         + " packet size: " + _payloadLength + " off: " + offset + " data: " + Base64.encode(_message));
}
public long readNonce() {

代码示例来源:origin: i2p/i2p.i2p

static final String toId(long id) {
  return Base64.encode(DataHelper.toLong(4, id)).replace("==", "");
}

代码示例来源:origin: i2p/i2p.i2p

/** what IP Alice is reachable on */
public void readIP(byte target[], int targetOffset) {
  int offset = readBodyOffset() + 4;
  int size = _message[offset] & 0xff;
  offset++;
  System.arraycopy(_message, offset, target, targetOffset, size);
  if (_log.shouldLog(Log.DEBUG))
    _log.debug("read alice ip: " + Base64.encode(target, targetOffset, size));
}
public int readPort() {

代码示例来源:origin: i2p/i2p.i2p

/** unused */
public void readChallengeSize(byte target[], int targetOffset) {
  int offset = readBodyOffset() + 4;
  offset += _message[offset] & 0xff;
  offset += 1 + 2;
  int sz = _message[offset] & 0xff;
  offset++;
  System.arraycopy(_message, offset, target, targetOffset, sz);
  if (_log.shouldLog(Log.DEBUG))
    _log.debug("read challenge data: " + Base64.encode(target));
}
public void readAliceIntroKey(byte target[], int targetOffset) {

代码示例来源:origin: i2p/i2p.i2p

/**
 *  @param keyData using first 24 bytes
 */
public NTCP2ReadState(CipherState rcvr, byte[] keyData) {
  _rcvr = rcvr;
  _sipk1 = fromLong8LE(keyData, 0);
  _sipk2 = fromLong8LE(keyData, 8);
  System.arraycopy(keyData, 16, _sipIV, 0, SIP_IV_LENGTH);
  if (_log.shouldDebug())
    _log.debug("Recv SipHash keys: " + _sipk1 + ' ' + _sipk2 + ' ' + Base64.encode(_sipIV));
}

代码示例来源:origin: i2p/i2p.i2p

/**
 *  @param realm e.g. i2cp, routerconsole, etc.
 *  @param user null or "" for no user, already trimmed
 *  @param pw plain text, already trimmed
 *  @return if pw verified
 */
public boolean checkB64(String realm, String user, String pw) {
  String pfx = realm;
  if (user != null && user.length() > 0)
    pfx += '.' + user;
  String b64 = _context.getProperty(pfx + PROP_B64);
  if (b64 == null)
    return false;
  return b64.equals(Base64.encode(DataHelper.getUTF8(pw)));
}

代码示例来源:origin: i2p/i2p.i2p

public void toRawString(StringBuilder buf) throws DataFormatException { 
    UDPPacketReader.this.toRawString(buf); 
    buf.append(" payload: ");
       
    int off = getFragmentBegin(0); // first fragment
    off += 4 + 1; // messageId + fragment info
    int size = ((int)DataHelper.fromLong(_message, off, 2)) & 0x3FFF;
    off += 2;
    buf.append(Base64.encode(_message, off, size));
  }
}

代码示例来源:origin: i2p/i2p.i2p

public void runJob() {
  // we know its a FooMessage, since thats the type of message that the handler
  // is registered as
  FooMessage m = (FooMessage)_msg;
  System.out.println("RECV FooMessage: " + Base64.encode(m.getData()) + " from " + _from);
}
public String getName() { return "Handle Foo message"; }

代码示例来源:origin: i2p/i2p.i2p

public long readSignedOnTime() {
  int offset = readBodyOffset() + Y_LENGTH + 1 + readIPSize() + 2 + 4;
  long rv = DataHelper.fromLong(_message, offset, 4);
  if (_log.shouldLog(Log.DEBUG))
    _log.debug("Signed on time offset: " + offset + " val: " + rv
          + "\nRawCreated: " + Base64.encode(_message, _payloadBeginOffset, _payloadLength));
  return rv;
}

相关文章