Giggo Posted February 22, 2022 Share Posted February 22, 2022 (edited) i wrote a program in c with cryptography and it works very well but in AutoIt3 can't figure out how to use the algorithm in question since system.random is not safe System.Security.Cryptography.RNGCryptoServiceProvider I use such code in c # and even if forced to generate 22 characters it is much safer than normal random using System; using System.Security.Cryptography; namespace HauntedHouseSoftware.SecureNotePad.Tools { public static class PasswordGenerator { public static string Generate(int passwordLength, bool singleCase) { if (passwordLength == 0) { throw new InvalidOperationException("passwordLength"); } string password; using (var randomNumberGenerator = new RNGCryptoServiceProvider()) { var randomNumber = new byte[64]; randomNumberGenerator.GetBytes(randomNumber); password = Convert.ToBase64String(randomNumber); } password = password.Substring(0, passwordLength); if (singleCase) { password = password.ToLower(); } return password; } } } me program c# private void Button1_Click(object sender, EventArgs e) { TextBox1.Text = GetRandomPassword(); } private string GetRandomPassword() { StringBuilder stringBuilder = new StringBuilder(); string text = Convert.ToBase64String(Guid.NewGuid().ToByteArray()); string text2 = text; int i = 0; for (int length = text2.Length; i < length; i = checked(i + 1)) { char c = text2[i]; if (char.IsLetterOrDigit(c)) { stringBuilder.Append(c); if (stringBuilder.Length == 30) { break; } } } return stringBuilder.ToString(); } Edited February 22, 2022 by Giggo Link to comment Share on other sites More sharing options...
ad777 Posted February 22, 2022 Share Posted February 22, 2022 @Giggo in Autoit you can use: https://www.autoitscript.com/autoit3/docs/libfunctions/_Crypt_EncryptData.htm https://www.autoitscript.com/autoit3/docs/libfunctions/_Crypt_GenRandom.htm Giggo 1 iam ِAutoit programmer. best thing in life is to use your Brain to Achieve everything you want. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now