Java XML Base64 Encode Decode toBase64Encoded(String unencoded)

Here you can find the source of toBase64Encoded(String unencoded)

Description

to Base Encoded

License

Open Source License

Declaration

public static String toBase64Encoded(String unencoded) 

Method Source Code

//package com.java2s;
/******************************************************************************* 
 * Copyright (c) 2012-2016 Red Hat, Inc. 
 * Distributed under license by Red Hat, Inc. All rights reserved. 
 * This program is made available under the terms of the 
 * Eclipse Public License v1.0 which accompanies this distribution, 
 * and is available at http://www.eclipse.org/legal/epl-v10.html 
 * /*from w  w  w  .j  a v a  2  s.  c  o  m*/
 * Contributors: 
 * Red Hat, Inc. - initial API and implementation 
 ******************************************************************************/

import javax.xml.bind.DatatypeConverter;

public class Main {
    public static String toBase64Encoded(String unencoded) {
        if (unencoded == null) {
            return null;
        } else if (unencoded.getBytes().length == 0) {
            return new String();
        }
        return DatatypeConverter.printBase64Binary(unencoded.getBytes());
    }
}

Related

  1. readFileToBase64(String filePath)
  2. sha256SaltBase64(String password, String salt)
  3. toB64(byte[] bytes)
  4. toBase10(String base64)
  5. toBase64(byte[] array)
  6. toBase64String(final byte[] data)
  7. toSafePathBase64(byte[] value)
  8. urlSafeBase64Decode(String in)