简体   繁体   English

如何从字符串中创建自己的哈希码?

[英]how to make my own hash code from string?

I am beginner in cryptography, but I want to make a simple hash code function in C. My concept is, I have a string "helloiam" and a integer 433 . 我是密码学的初学者,但是我想在C中创建一个简单的哈希码函数。我的概念是,我有一个字符串"helloiam"和一个整数433 Can I convert the string in to encrypted format like "233ASDJJ6688FGSS" something like that? 我可以将字符串转换为类似"233ASDJJ6688FGSS"加密格式吗?
I don't know unsigned integer or 128 bit integer format. 我不知道无符号整数或128位整数格式。 Any simple code to convert string using a integer to form a hash code. 任何使用整数将字符串转换为哈希码的简单代码。 I generate that unique integer for every string. 我为每个字符串生成该唯一整数。 But I want to use this integer on the string to form a hash code like "233ASDJJ6688FGSS" . 但是我想在字符串上使用此整数来形成类似"233ASDJJ6688FGSS"的哈希码。
How can I make this? 我该怎么做?
Any sample code in C? C中有任何示例代码吗?
I don't want to make complex algorithms for making hash code. 我不想制作复杂的算法来制作哈希码。 I am try to make my own. 我试图使自己的。

Hash function can only give you more or less long integer values , the format with character is a formatting of the integer, like converting it to a string or formatting it with printf 哈希函数只能为您提供或多或少的长整数值 ,字符格式是整数格式,例如将其转换为字符串或使用printf格式化

Some well known integer formatting available are : 一些众所周知的整数格式可用:

  • binary (base 2) 二进制(以2为底)
  • octal (base 8) 八进制(以8为底)
  • decimal ( base 10 ) 十进制(以10为底)
  • hexadecimal ( base 16) 十六进制(以16为底)
  • base64 base64
    ... ...

you can of course roll your own by choosing a base for your number, meaning how many characters are in your figures list to write your number. 当然,您可以通过选择数字的底数来滚动自己的数字,这意味着数字列表中有多少个字符可以写出您的数字。
You can then write a correspondence table to match the number with the correct character. 然后,您可以编写一个对应表,以将数字与正确的字符进行匹配。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM