markus / KCOM / Common / Commons.cs @ 5a223b60
이력 | 보기 | 이력해설 | 다운로드 (1.05 KB)
1 | 03960fa5 | taeseongkim | using System; |
---|---|---|---|
2 | 4b33593a | taeseongkim | using System.Text; |
3 | 24678e06 | humkyung | |
4 | namespace KCOM.Common |
||
5 | { |
||
6 | public class Commons |
||
7 | { |
||
8 | 5a223b60 | humkyung | public static string ShortGuid() |
9 | 24678e06 | humkyung | { |
10 | 4b33593a | taeseongkim | 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 | 24678e06 | humkyung | //강인구 추가 |
27 | 5a223b60 | humkyung | public static string ShortFileKey() |
28 | 24678e06 | humkyung | { |
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 | } |