当前位置:网站首页>String to Base64

String to Base64

2022-06-24 08:41:00 Simon66991

public class Base64Util {
    

    private static final String UTF_8 = "UTF-8";
    private static final String TAG = "Base64";

    /** *  To the given string base64 Decoding operation  */
    public static String decodeData(String inputData) {
    
        try {
    
            if (null == inputData) {
    
                return null;
            }
            return new String(Base64.decodeBase64(inputData.getBytes(UTF_8)), UTF_8);
        } catch (UnsupportedEncodingException e) {
    
            Log.d(TAG, "encodeData: ", e);
        }

        return null;
    }

    /** *  To the given string base64 Encryption operation  */
    public static String encodeData(String inputData) {
    
        try {
    
            if (null == inputData) {
    
                return null;
            }
            return new String(Base64.encodeBase64(inputData.getBytes(UTF_8)), UTF_8);
        } catch (UnsupportedEncodingException e) {
    
            Log.d(TAG, "encodeData: ", e);
        }

        return null;
    }

}

原网站

版权声明
本文为[Simon66991]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/175/202206240608212084.html