gpt4 book ai didi

C#程序在添加断点时在不同的文件中生成相同的输出

转载 作者:太空宇宙 更新时间:2023-11-03 19:46:47 24 4
gpt4 key购买 nike

<分区>

我想生成 160 个不同的随机用户和密码,现在当我在用户和密码变量上添加断点(在 for 循环中)时,代码似乎可以正常工作。但是当我在没有断点的情况下运行我的代码时,Passwords.csv 对所有 160 行都有相同的输出。感谢任何帮助

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace WriteCSVPasswords
{
class Program
{
static void Main(string[] args)
{
string path = @"c:\temp\Passwords.csv";
string user = null;
string password = null;
string[] file = new string[160];

for (int i = 0; i < 160; i++)
{
user = CreatePassword(4);
password = CreatePassword(5);
file[i] = user + ";" + password + ";" + Base64Encode(user + ":" + password);
user = null;
password = null;
}

if (!File.Exists(path))
{
// Create a file to write to.
File.WriteAllLines(path, file, Encoding.UTF8);
}



}

public static string CreatePassword(int length)
{
const string valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.+-!";
StringBuilder res = new StringBuilder();
Random rnd = new Random();
while (0 < length--)
{
res.Append(valid[rnd.Next(valid.Length)]);
}
return res.ToString();
}

public static string Base64Decode(string base64EncodedData)
{
var base64EncodedBytes = System.Convert.FromBase64String(base64EncodedData);
return System.Text.Encoding.UTF8.GetString(base64EncodedBytes);
}
public static string Base64Encode(string plainText)
{
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);
return System.Convert.ToBase64String(plainTextBytes);
}
}
}

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com