프로젝트

일반

사용자정보

통계
| 개정판:

hytos / ID2.Manager / ID2.Manager.Common / Globals.cs @ 677a1d1f

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

1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6

    
7
using System.IO;
8
using System.Security.Cryptography;
9
using System.Text.RegularExpressions;
10

    
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
                return "Samsung IDUS";
35
            }
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
        public static string Base64Encoding(string EncodingText, Encoding oEncoding = null)
48
        {
49
            if (oEncoding == null)
50
                oEncoding = Encoding.UTF8;
51

    
52
            byte[] arr = oEncoding.GetBytes(EncodingText);
53
            return System.Convert.ToBase64String(arr);
54
        }
55

    
56
        public static string Base64Decoding(string DecodingText, Encoding oEncoding = null)
57
        {
58
            if (oEncoding == null)
59
                oEncoding = Encoding.UTF8;
60

    
61
            byte[] arr = System.Convert.FromBase64String(DecodingText);
62
            return oEncoding.GetString(arr);
63
        }
64

    
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

    
70
        public static string ProgramDataFolder
71
        {
72
            get
73
            {
74
                return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "ID2Manager");
75
            }
76
        }
77
    }
78
}
클립보드 이미지 추가 (최대 크기: 500 MB)