使用C#生成唯一密钥 [英] Generate unique Key using C#

查看:399
本文介绍了使用C#生成唯一密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,

我必须使用c#生成具有6(数字+字母)的唯一键,即数字和字母的组合.

请朋友帮我.

在此先感谢...

Hello friends,

I have to generate a Unique Key using c# which have 6(Digits+Letters) i.e combination of both digits and letters.

Please friends help me.

Thanks in advance...

推荐答案

您计划生成的密钥永远不会唯一.
您将有可能重复此组合(因为只有6个字符).

改为使用GUID [
This key that you plan to generate can never be unique.
You will have a possibility of repeating this combination (since you have only 6 characters).

Use a GUID instead[^].


我会尝试使用54个大写/小写字母+ 10个数字+''?=()[] {}&%#!+''对ip地址进行编码,从而为您提供78个字符供您选择.

这足以编码任何32位值(ipv4地址为32位),然后再编码为6个字符.

最好的问候
Espen Harlinn
I''d try encoding the ip address using the 54 upper/lower case characters + the 10 digits + ''?=()[]{}&%#!+'' giving you 78 characters to choose from.

That''s sufficient to encode any 32-bit value (ipv4 address is 32 bits), and then some, in 6 characters.

Best regards
Espen Harlinn


这篇关于使用C#生成唯一密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆