public static byte[] GetMachineConstant(int bytesCount) { var cnst = Enumerable.Repeat<byte>(0, sizeof(int)).Concat(GetMachineConstant()).ToArray(); var icnst = BitConverter.ToInt32(cnst, cnst.Length - sizeof(int)); var rnd = new AscRandom(icnst); var buff = new byte[bytesCount]; rnd.NextBytes(buff); return buff; }
private static byte[] GetSK(int seed) { var random = new AscRandom(seed); var randomKey = new byte[32]; for (var i = 0; i < randomKey.Length; i++) { randomKey[i] = (byte)random.Next(byte.MaxValue); } return(randomKey); }
public static string GeneratePassword(int length) { const string noise = "1234567890mnbasdflkjqwerpoiqweyuvcxnzhdkqpsdk"; var random = new AscRandom(); var pwd = string.Empty; while (0 < length--) { pwd += noise[random.Next(noise.Length)]; } return(pwd); }