using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SvetoforVKBot.Services { public class PasswordService { public static string GeneratePassword() { int length = 6; StringBuilder password = new StringBuilder(); Random random = new Random(); while (password.Length < length) { int c = random.Next(0, 9); password.Append(c); } return password.ToString(); } public static string CreateMD5(string input) { // Use input string to calculate MD5 hash using (System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create()) { byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input); byte[] hashBytes = md5.ComputeHash(inputBytes); // Convert the byte array to hexadecimal string StringBuilder sb = new StringBuilder(); for (int i = 0; i < hashBytes.Length; i++) { sb.Append(hashBytes[i].ToString("X2")); } return sb.ToString().ToLower(); } } } }