using System;
using System.Text;

namespace SGModule.Common.Helper {
    public static class Base64Helper {
        public static string Encode(string source) {
            return Base64Encode(Encoding.UTF8, source);
        }

        public static string Decode(string result) {
            return Base64Decode(Encoding.UTF8, result);
        }

        private static string Base64Encode(Encoding encoding, string source) {
            var bytes = encoding.GetBytes(source);
            var encode = Convert.ToBase64String(bytes);
            return encode;
        }

        private static string Base64Decode(Encoding encoding, string result) {
            var bytes = Convert.FromBase64String(result);
            var decode = encoding.GetString(bytes);
            return decode;
        }
    }
}
