<p>
toBase64.
</p>

@param user
a {@link java.lang.String} object.
@param password
a {@link java.lang.String} object.
@return a {@link java.lang.String} object.
763993
protected String toBase64(String user, String password) {
		StringBuffer stringBuffer = new StringBuffer();
		stringBuffer.append(user);
		stringBuffer.append(":");
		stringBuffer.append(password);
		return Base64Utility.encode(stringBuffer.toString().getBytes());
	}
409589
public static String serializeToBase64(Serializable object)  {
        Objects.requireNonNull(object, Required.OBJECT.toString());
        
        byte[] serialize = SerializationUtils.serialize(object);
        return base64Encoder.encodeToString(serialize);
    }
441305
public static String[] encrypt(String password) {
        SecureRandom random = new SecureRandom();
        String salt = new BigInteger(130, random).toString(32);
        String encryptPassword = encrypt(password, salt);
        return new String[] {encryptPassword, salt};
    }
1013552
public String depass(String password) throws IOException {
	  if(password==null)return null;
	  ByteArrayOutputStream baos = new ByteArrayOutputStream();
	  depass(password,baos);
	  return new String(baos.toByteArray());
  }
1196916
protected String buildBasicAuthValue(String user, String password){
		StringBuilder sb = new StringBuilder();
		if (StringUtils.isNotEmpty(user)){
			sb.append(user);
		}
		if (StringUtils.isNotEmpty(password)){
			if (sb.length() > 0){
				sb.append(':');
			}
			sb.append(password);
		}
		return buildBasicAuthValue(sb.toString());
	}
895705
public UserRecoverRequest requestRecover(User user) {
		if (user == null)
			return null;
		UserRecoverRequest req = new UserRecoverRequest();
		req.setUser(user);
		req.setCreation(new Date());
		req.setCreationIp(this.request.getRemoteAddr());
		req.setExpiration(new Date(System.currentTimeMillis() + 1800000L));
		req.setToken(CryptManager.digest(Math.random() + "@" + System.currentTimeMillis() + "#" + user.getEmail()));
		this.dao.persist(req);
		// TODO Send the recovering email.
		return req;
	}
756270
private String normalize(String user) {
        if(user != null){
            if(user.contains("@"))
                user = user.replaceAll("@", "%40");
        }
        if(logger.isDebugEnabled())
            logger.debug("Normalized User = " + user);
        return user;
    }
626610
function convertToBase64(input) {
        var result = "";
        var charCodes = getExpandedCharCodes(input);
        var i = 0;
        var length = charCodes.length;
        var byte1, byte2, byte3, byte4;
        while (i < length) {
            // Convert every 6-bits in the input 3 character points
            // into a base64 digit
            byte1 = charCodes[i] >> 2;
            byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4;
            byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6;
            byte4 = charCodes[i + 2] & 63;
            // We are out of characters in the input, set the extra
            // digits to 64 (padding character).
            if (i + 1 >= length) {
                byte3 = byte4 = 64;
            }
            else if (i + 2 >= length) {
                byte4 = 64;
            }
            // Write to the output
            result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4);
            i += 3;
        }
        return result;
    }
411978
public static String encodeBase64(final String data) {
        return Base64.encodeBase64String(data.getBytes(StandardCharsets.UTF_8));
    }
812505
public static String decodeBase64(String content, TestContext context) {
        return new DecodeBase64Function().execute(Collections.singletonList(content), context);
    }
714660
public Request authorize(String name, String password){
        String authString = name + ":" + password;
        System.out.println("auth string: " + authString);
        byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
        String authStringEnc = new String(authEncBytes);
        System.out.println("Base64 encoded auth string: " + authStringEnc);
        return this.authorization("Basic " + authStringEnc);

    }
440780
public String asBase64(BaseEncoding.Dialect dialect, BaseEncoding.Padding padding) throws IOException {
        String standardBase64 = DatatypeConverter.printBase64Binary(asByteArray(false));
        if (dialect == BaseEncoding.Dialect.STANDARD && padding == BaseEncoding.Padding.STANDARD) {
            return standardBase64;
        }

        StringBuilder safeBase64 = new StringBuilder(standardBase64.length());
        for(int i=0; i<standardBase64.length(); i++) {
            char c = standardBase64.charAt(i);

            if (dialect == BaseEncoding.Dialect.SAFE) {
                if (c == '+') c = '-';
                else if (c == '/') c = '_';
            }

            if (c == '=') {
                if (padding == BaseEncoding.Padding.STANDARD) {
                    safeBase64.append('=');
                }
                else if (padding == BaseEncoding.Padding.SAFE) {
                    safeBase64.append('.');
                }
            } else {
                safeBase64.append(c);
            }
        }
        return safeBase64.toString();
    }
108084
public static byte[] decodeBase64(String value) {
        int byteShift = 4;
        int tmp = 0;
        boolean done = false;
        final StringBuilder buffer = new StringBuilder();

        for (int i = 0; i != value.length(); i++) {
            final char c = value.charAt(i);
            final int sixBit = (c < 123) ? EncodingGroovyMethodsSupport.TRANSLATE_TABLE[c] : 66;

            if (sixBit < 64) {
                if (done)
                    throw new RuntimeException("= character not at end of base64 value"); // TODO: change this exception type

                tmp = (tmp << 6) | sixBit;

                if (byteShift-- != 4) {
                    buffer.append((char) ((tmp >> (byteShift * 2)) & 0XFF));
                }

            } else if (sixBit == 64) {

                byteShift--;
                done = true;

            } else if (sixBit == 66) {
                // RFC 2045 says that I'm allowed to take the presence of
                // these characters as evidence of data corruption
                // So I will
                throw new RuntimeException("bad character in base64 value"); // TODO: change this exception type
            }

            if (byteShift == 0) byteShift = 4;
        }

        try {
            return buffer.toString().getBytes("ISO-8859-1");
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException("Base 64 decode produced byte values > 255"); // TODO: change this exception type
        }
    }
282344
@Override
	public String decode(String password) {
		if (password.startsWith(PASSWORD_PREFIX)) {
			password = password.substring(PASSWORD_PREFIX.length());
			return JKSecurityUtil.decode(new String(JKSecurityUtil.decrypt(password.getBytes())));
		}
		return password;
	}
1067574
public static String encodeHttpBasic(final String username, final String password) {
		String encode = username + ':' + password;
		return "Basic " + Base64.encodeBase64String(encode.getBytes(Charsets.UTF_8));
	}
778462
public static String base64Decode(final String value) {
        validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
        return new String(Base64.getDecoder().decode(value), StandardCharsets.UTF_8);
    }
1037122
public static String toBase64(byte[] byteArray) {

        String result = null;
        if (byteArray != null) {
            result = Base64.encodeBase64String(byteArray);
        }
        return result;
    }