프로젝트

일반

사용자정보

통계
| 개정판:

hytos / ID2.Manager / ID2.Manager.Common / Globals.cs @ 56d59bde

이력 | 보기 | 이력해설 | 다운로드 (2.08 KB)

1 35d01ef5 yoush97
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6
7 677a1d1f yoush97
using System.IO;
8 35d01ef5 yoush97
using System.Security.Cryptography;
9 c52f8bbe yoush97
using System.Text.RegularExpressions;
10 35d01ef5 yoush97
11
namespace ID2.Manager.Common
12
{
13
    public class Globals
14
    {
15
        private static Globals m_Globals;
16
17
        public static Globals GetInstance
18
        {
19
            get
20
            {
21
                if (m_Globals == null)
22
                {
23
                    m_Globals = new Globals();
24
                }
25
26
                return m_Globals;
27
            }
28
        }
29
30
        public static string Name
31
        {
32
            get
33
            {
34 296ffcbd yoush97
                return "Samsung IDUS";
35 35d01ef5 yoush97
            }
36
        }
37
38
        public static string EncryptionSHA256(string Data)
39
        {
40
            using (SHA256 sha = new SHA256Managed())
41
            {
42
                return Convert.ToBase64String(sha.ComputeHash(Encoding.UTF8.GetBytes(Data)));
43
44
            }
45
        }
46
47 c52f8bbe yoush97
        public static string Base64Encoding(string EncodingText, Encoding oEncoding = null)
48 35d01ef5 yoush97
        {
49
            if (oEncoding == null)
50 c52f8bbe yoush97
                oEncoding = Encoding.UTF8;
51 35d01ef5 yoush97
52
            byte[] arr = oEncoding.GetBytes(EncodingText);
53
            return System.Convert.ToBase64String(arr);
54
        }
55
56 677a1d1f yoush97
        public static string Base64Decoding(string DecodingText, Encoding oEncoding = null)
57 35d01ef5 yoush97
        {
58
            if (oEncoding == null)
59 c52f8bbe yoush97
                oEncoding = Encoding.UTF8;
60 35d01ef5 yoush97
61
            byte[] arr = System.Convert.FromBase64String(DecodingText);
62 677a1d1f yoush97
            return oEncoding.GetString(arr);
63 35d01ef5 yoush97
        }
64 c52f8bbe yoush97
65
        public static bool IsMatchEmailFormat(string EmailText)
66
        {
67
            return Regex.IsMatch(EmailText, @"[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?");
68
        }
69 677a1d1f yoush97
70
        public static string ProgramDataFolder
71
        {
72
            get
73
            {
74
                return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "ID2Manager");
75
            }
76
        }
77 35d01ef5 yoush97
    }
78
}
클립보드 이미지 추가 (최대 크기: 500 MB)