我需要代码从我的两个输入组合生成64个字符的密钥(每个输入有12个数字) [英] I need code to generate 64 character key from combination of my two inputs(having 12 digits each)

查看:91
本文介绍了我需要代码从我的两个输入组合生成64个字符的密钥(每个输入有12个数字)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..我需要代码从我的两个输入的组合中生成64个字符的密钥(每个都有12个数字)。这64个字符的输出应该是唯一的..如果我再次给出相同的输入,那么也应该是相同..

有可能请给出解决方案..

解决方案

任何确定性算法都可以解决问题。例如,简单地连接输入键就可以了:

  string  k1 =   123456789012; 
string k2 = 135792468013;
string kr = k1 + k2 + k1 + k2 + k1 + k2.SubString( 0 4 );


执行此操作的最佳方法可能是使用散列函数:无论输入长度如何,SHA256都会产生256位输出,相当于64位十六进制数字(即64个可打印字符)输出。



请参见: SHA256类 [ ^ ]

Hi..I need code to generate 64 character key from the combination of my two inputs(having 12 digits each).And that 64 character output should be unique..if i give the same inputs again the out also should be same..
It is possible please give solution..

解决方案

Any deterministic algorithm would do the trick. For instance simply concatenating the input keys would work:

string k1 = "123456789012";
string k2 = "135792468013";
string kr = k1 + k2 + k1 + k2 + k1 + k2.SubString(0,4);


Probably the best way to do this would be to use a hashing function: SHA256 produces a 256 bit output regardless of the input length, which equates to a 64 hex digit (ie 64 printable characters) output.

See here: SHA256 Class[^]


这篇关于我需要代码从我的两个输入组合生成64个字符的密钥(每个输入有12个数字)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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