markus / KCOM / Common / Commons.cs @ 5a223b60
이력 | 보기 | 이력해설 | 다운로드 (1.05 KB)
1 |
using System; |
---|---|
2 |
using System.Text; |
3 | |
4 |
namespace KCOM.Common |
5 |
{ |
6 |
public class Commons |
7 |
{ |
8 |
public static string ShortGuid() |
9 |
{ |
10 |
char[] chars = "ABCDEF1234567890".ToCharArray(); |
11 |
byte[] data = new byte[1]; |
12 |
System.Security.Cryptography.RNGCryptoServiceProvider crypto = new System.Security.Cryptography.RNGCryptoServiceProvider(); |
13 |
crypto.GetNonZeroBytes(data); |
14 |
data = new byte[32]; |
15 |
crypto.GetNonZeroBytes(data); |
16 |
StringBuilder result = new StringBuilder(32); |
17 | |
18 |
foreach (byte b in data) |
19 |
{ |
20 |
result.Append(chars[b % (chars.Length - 1)]); |
21 |
} |
22 | |
23 |
return result.ToString(); |
24 |
} |
25 | |
26 |
//강인구 추가 |
27 |
public static string ShortFileKey() |
28 |
{ |
29 |
//byte[] bytes = new byte[3]; |
30 |
//using (var provider = System.IO.Path.GetRandomFileName()) |
31 |
//{ |
32 |
// provider.GetBytes(bytes); |
33 |
//} |
34 | |
35 |
return System.IO.Path.GetRandomFileName(); |
36 |
} |
37 |
} |
38 |
} |