密钥生成算法 [英] key generation algorithm

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

问题描述

大家

我正在开发dektop应用程序

i am working on dektop application

我想要一个密钥生成算法

i want a algorithm for key generation

当传递任何值时,此算法返回相同的值

when pass any value this algo return same value

就像 如果你传递"你好"这个算法返回零

just like  if you pass "hello" this algo return zero

当你传递"hello world"时这个算法也应该返回零

and when you pass "hello world" this algo should also return zero

请帮助我紧急

提前感谢

推荐答案

"你好"之间的区别是什么?和"你好世界"导致这两者都返回0?  您是否只想处理字符串中的第一个单词?  前5个字母?

What is the difference between "hello" and "hello world" which causes these both to return 0?  Do you just want to work off the first word in the string?  The first 5 letters?

 

您可以执行以下操作:

 


int GenerateKey(string input)
{
  input = input.Trim();

  if (input.Contains(" "))
  {
    input = input.Split(' ')[0]; // Grab the first word only
  }

  return input.GetHashCode(); // Generate a unique "key"
}


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

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