public static String encode(String data) { if (data == null) { return null; } return encode(Misc.getBytesUTF8(data)); }
/** * Generate a value for Sec-WebSocket-Key. * * <blockquote> * <p><i> * The request MUST include a header field with the name Sec-WebSocket-Key. * The value of this header field MUST be a nonce consisting of a randomly * selected 16-byte value that has been base64-encoded (see Section 4 of * RFC 4648). The nonce MUST be selected randomly for each connection. * </i></p> * </blockquote> * * @return * A randomly generated WebSocket key. */ private static String generateWebSocketKey() { // "16-byte value" byte[] data = new byte[16]; // "randomly selected" Misc.nextBytes(data); // "base64-encoded" return Base64.encode(data); }
private void addProxyAuthorization(StringBuilder builder) { String id = mSettings.getId(); if (id == null || id.length() == 0) { return; } String password = mSettings.getPassword(); if (password == null) { password = ""; } // {id}:{password} String credentials = String.format("%s:%s", id, password); // The current implementation always uses Basic Authentication. builder .append("Proxy-Authorization: Basic ") .append(Base64.encode(credentials)) .append(RN); }
headers.add(new String[] { "Authorization", "Basic " + Base64.encode(mUserInfo) } );
expected = Base64.encode(digest);
public static String encode(String data) { if (data == null) { return null; } return encode(Misc.getBytesUTF8(data)); }
/** * Generate a value for Sec-WebSocket-Key. * * <blockquote> * <p><i> * The request MUST include a header field with the name Sec-WebSocket-Key. * The value of this header field MUST be a nonce consisting of a randomly * selected 16-byte value that has been base64-encoded (see Section 4 of * RFC 4648). The nonce MUST be selected randomly for each connection. * </i></p> * </blockquote> * * @return * A randomly generated WebSocket key. */ private static String generateWebSocketKey() { // "16-byte value" byte[] data = new byte[16]; // "randomly selected" Misc.nextBytes(data); // "base64-encoded" return Base64.encode(data); }
private void addProxyAuthorization(StringBuilder builder) { String id = mSettings.getId(); if (id == null || id.length() == 0) { return; } String password = mSettings.getPassword(); if (password == null) { password = ""; } // {id}:{password} String credentials = String.format("%s:%s", id, password); // The current implementation always uses Basic Authentication. builder .append("Proxy-Authorization: Basic ") .append(Base64.encode(credentials)) .append(RN); }
headers.add(new String[] { "Authorization", "Basic " + Base64.encode(mUserInfo) } );
expected = Base64.encode(digest);