/** * 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) : ""); }
@Override public String toBase64() { if (_data == null) return null; return Base64.encode(_data); }
/** * 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) : ""); }
/** * 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) : ""); }
public final String toBase64() { return Base64.encode(_data, _offset, _valid); } }
public void toRawString(StringBuilder buf) { if (_message != null) buf.append(Base64.encode(_message, _payloadBeginOffset, _payloadLength)); }
public String toBase64() { byte data[] = toByteArray(); if (data == null) return null; return Base64.encode(data); }
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); }
/** * 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)) : ""); }
/** * 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(); }
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)); }
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() {
static final String toId(long id) { return Base64.encode(DataHelper.toLong(4, id)).replace("==", ""); }
/** 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() {
/** 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) {
/** * @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)); }
/** * @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))); }
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)); } }
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"; }
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; }