gpt4 book ai didi

c# - 从 int 到短字符串的 2 路加密

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

我正在构建一个微型网络应用程序,我们的客户可以在其中更新有关其公司的一些详细信息。客户目前没有登录名/密码,我们不想验证他们的注册,所以我们想给他们一个自动生成的密码/ key 来登录网站。

我们计划加密他们的 customerId 并将其提供给客户,以便他可以在网络应用程序上输入该 key ,以便我们将 key 解密为他的 ID。

大约有 10,000 名客户,他们并不都拥有电子邮件,因此有些人会收到一封包含 URL 和代码的信件。这意味着客户必须输入代码,因此代码不能超过 8 个字符(最好是 6 个)。

这是一个空模板:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int passwordLength = 6;
int customerId = 12345;
string encrypted = Crypter.Encrypt(customerId, "secretKey", passwordLength);
if (customerId == Crypter.Decrypt(encrypted, "secretKey"))
{
Console.WriteLine("It worked! Well done!");
}
}

}

public static class Crypter
{
public static string Encrypt(int input, string key, int passwordLength)
{
string encryptedString = "";
//do encrypt stuffz here

return encryptedString;
}
public static int Decrypt(string encryoted, string key)
{
int decrypted = 0;
//do decrypt stuffz here

return decrypted;
}
}
}

=> 任何人都可以将我链接到有关如何执行此操作的更多信息吗?

我不是在寻找“请将代码发送给我”,但如果有人已经制作了类似的东西,请随时分享。

提前感谢您提供任何信息。

最佳答案

不要将您的密码基于用户 ID。相反,为每个客户生成一个随机的 6 个字符的字符串并将其存储在数据库中。它不容易找到实际算法。

关于c# - 从 int 到短字符串的 2 路加密,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/887565/

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