字符串唯一的整数哈希 [英] String to unique integer hashing

查看:226
本文介绍了字符串唯一的整数哈希的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图建立一个系统,可以改变我的字符串转换成一个唯一的整数值,这意味着说,例如单词账户有0891加密的数值并没有其他字可能被转换为0891的相同的转换方法,它的然而需要能够被转换回所生成的整数到字符串

I'm trying to develop a system that can change my string into a unique integral value, meaning say for example the word "account" has an encrypted numerical value of 0891 and no other word can possibly be converted to 0891 with the same conversion process, it does not however need to be able to be converted back the generated integer to string.

同时,它会依赖于字结构的规则,这意味着诸如准确度和公告,将有超过0891和诸如一,算盘和缩写生成的数量越多将具有产生数小于0891

At the same time it will be dependent on the word structure rules, meaning words such as "accuracy" and "announcement" will have a generated number greater than 0891 and words such as "a", "abacus" and "abbreviation" will have a generated number less than 0891.

本申请的目的是为类似于索引或主键。为什么我不使用增量指标的原因是出于安全目的,是由于索引依赖于数据的数量在集合

The purpose of this application is to serve similar to an index or primary key. The reason why I'm not using an increment index is for security purposes and is due to the indexes dependency to the number of data in the set

(例如)

[0] A, [1] B, [2] C, [3] D, [4] E, [5] F

上面的字母都有各自相应的指数,E为4的指数

The above letters has each corresponding index, E has the index of 4

但是,如果该数据被突然增加或减少再排序

However if the data is suddenly increased or decreased then sorted

[0] A, [1] AA, [2] AAB, [3] C, [4] D, [5] DA, [6] DZ, [7] E, [8] F

电子目前拥有7索引

每个字必须具有唯一的独立积分当量,并具有相应的权重。

Each word must have a unique independent integral equivalent and has the corresponding weights.

我需要知道,如果存在一个算法,能够做到以上。

I need to know if there exist an algorithm that can do the above.

任何帮助将AP preciated。

Any help will be appreciated.

推荐答案

这是不可能的,你给的约束,除非你施加的最大长度。

This is not possible with the constraints you have given, unless you impose a maximum length.

假设 K(A) K(B)是codeS这两个字符串。

Assume that k("a") and k("b") are the codes of these two strings.

使用您的约束,你正在寻找属于插图中这两个值,但 K(A)℃的唯一整数; K(一个....一)LT; K(B)。由于存在着风格的字符串无限数量一....一个(和akjhdsfkjhs)这将需要适合插图中两个codeS,这样的的为了preserving 的一般,独特的,固定长度的code不能任意长度的字符串存在。因为你需要尽可能多的整数作为字符串,因为字符串不是由长度为界这可不行。

With your constraints, you are looking for a unique integer number that falls inbetween these two values, but k("a") < k("a....a") < k("b"). As there is an infinite number of strings of style "a....a" (and "akjhdsfkjhs") that would need to fit inbetween the two codes, such an order preserving general, unique, fixed-length code cannot exist for strings of arbitrary length. Because you would need as many integers as strings, and since strings are not bounded by length this cannot work.

删除或者一般的(所以不允许插入新的字符串),唯一的(允许collissions - 例如使用前四个字母为code),无界的长度(以例如3个字符)或命令─preserving属性。

Drop either general (so don't allow inserting new strings), unique (allow collissions - e.g. use the first four letters as code!), the unbounded length (to e.g. 3 characters) or the order-preserving property.

这篇关于字符串唯一的整数哈希的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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