using System; using System.Collections.Generic; using System.Linq; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; namespace HH.WCS.Hexafluo.util { internal class StrHelper { /// /// 获取随机字符串 /// /// /// /// public static string StrRandom(string prefix, int Length) { byte[] b = new byte[32]; RandomNumberGenerator.Create().GetBytes(b); Random random = new Random(BitConverter.ToInt32(b, 0)); string str = "0123456789"; //abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ string returnStr = string.Empty; for (int i = 0; i < Length; i++) { returnStr += str.Substring(random.Next(0, str.Length - 1), 1); } var cntrCode = prefix + returnStr; return cntrCode; } } }