从GUID生成20字节的int? [英] generate 20 byte int from GUID ?

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

问题描述

是否可以从GUID生成一个20字节的整数,该GUID是唯一的足够多的足够多的b $ b。 (就像GUID不是真正独特的,但是足够独特)。


我们用GUID标识交易,但合作伙伴网络服务有20美元b $ b传递的事务ID的字节限制。

解决方案

John Grandy写道:

是否可以生成20来自GUID的字节整数是唯一的足够的。 (就像GUID不是真正独特的,但是足够独特)。

我们使用GUID识别事务,但合作伙伴Web服务对事务ID具有20字节限制通过。




20字节= 160位。大多数GUID都是128位,20字节限制应该足够使用标准GUID




-

Rob Schieber


第三方'的TransactionID的20字节表示必须是一个字符串。

所以每个字节包含一个字符( ASCII编码)。因此,尽管有20个字节可用,但当转换为整数时,这仅对应于20个/ b $ b个半字节或10个字节。因此,我们需要将32个半字节GUID转换为20个半字节

psuedo-GUID。


" Rob Schieber" < SC ****** @ hotmail.com>在消息中写道

news:uG ************** @ TK2MSFTNGP12.phx.gbl ...

John Grandy写道:< blockquote class =post_quotes>是否可以从GUID生成一个20字节的整数,该整数是唯一的足够的。 (就像GUID并不是真正独一无二的,但是足够多了)。

我们用GUID标识交易,但合作伙伴网络服务有20个字节传递的事务ID限制。



20字节= 160位。大多数GUID是128位,20字节的限制应该足以使用标准GUID。

-
Rob Schieber



John Grandy写道:

第三方'的TransactionID的20字节表示必须是一个字符串。
所以每个字节包含一个字符( ASCII编码)。因此,尽管有20个字节可用,但当转换为整数时,这仅对应于20个半字节或10个字节。所以我们需要将32个半字节GUID转换为20个半字节
psuedo-GUID。

Rob Schieber < SC ****** @ hotmail.com>在消息中写道
新闻:uG ************** @ TK2MSFTNGP12.phx.gbl ...

John Grandy写道:

是否可以从GUID生成一个20字节的整数,该整数是唯一的足够的。 (就像GUID并不是真正独一无二的,但是足够多了)。

我们用GUID标识交易,但合作伙伴网络服务有20个字节传递的事务ID限制。



20字节= 160位。大多数GUID是128位,20字节的限制应该足以使用标准GUID。

-
Rob Schieber





啊,好吧我猜这一切都取决于如何创建GUIDS。我相信

GUID是使用适配器地址和

时间戳的组合生成的,也就是说,我怀疑如果你是唯一性将是一个问题

截断GUID的一部分。


如果你真的担心你可能想要根据标准生成你的b
自己的20个半字节GUID这将保证唯一性。


-

Rob Schieber


Is it possible to generate a 20 byte integer from a GUID that is "unique
enough" ( just like a GUID is not truly unique , but is "unique enough" ).

We identify transactions with GUIDs , but a partner web service has a 20
byte limit on transaction ID passed.

解决方案

John Grandy wrote:

Is it possible to generate a 20 byte integer from a GUID that is "unique
enough" ( just like a GUID is not truly unique , but is "unique enough" ).

We identify transactions with GUIDs , but a partner web service has a 20
byte limit on transaction ID passed.



20 bytes = 160 bits. Most GUIDs are 128 bits, a 20 byte limit should be
more than enough to use a standard GUID.

--
Rob Schieber


The 3rd party''s 20 byte representation of a TransactionID must be a string.
So each byte contains one character (ASCII coding). So although 20 bytes
are available, when converted to an integer this only corresponds to 20
nibbles or 10 bytes. So we need to convert a 32 nibble GUID to a 20 nibble
"psuedo-GUID".

"Rob Schieber" <sc******@hotmail.com> wrote in message
news:uG**************@TK2MSFTNGP12.phx.gbl...

John Grandy wrote:

Is it possible to generate a 20 byte integer from a GUID that is "unique
enough" ( just like a GUID is not truly unique , but is "unique
enough" ).

We identify transactions with GUIDs , but a partner web service has a 20
byte limit on transaction ID passed.



20 bytes = 160 bits. Most GUIDs are 128 bits, a 20 byte limit should be
more than enough to use a standard GUID.

--
Rob Schieber



John Grandy wrote:

The 3rd party''s 20 byte representation of a TransactionID must be a string.
So each byte contains one character (ASCII coding). So although 20 bytes
are available, when converted to an integer this only corresponds to 20
nibbles or 10 bytes. So we need to convert a 32 nibble GUID to a 20 nibble
"psuedo-GUID".

"Rob Schieber" <sc******@hotmail.com> wrote in message
news:uG**************@TK2MSFTNGP12.phx.gbl...

John Grandy wrote:

Is it possible to generate a 20 byte integer from a GUID that is "unique
enough" ( just like a GUID is not truly unique , but is "unique
enough" ).

We identify transactions with GUIDs , but a partner web service has a 20
byte limit on transaction ID passed.



20 bytes = 160 bits. Most GUIDs are 128 bits, a 20 byte limit should be
more than enough to use a standard GUID.

--
Rob Schieber




Ah, ok I guess it all depends on how the GUIDS are created. I believe
GUIDs are generated using a combination of the Adapter Address and a
timestamp, that said, I doubt that uniqueness will be a problem if you
truncate a section of the GUID.

If you are really concerned you may want to look into generating your
own 20 nibble GUIDs according to criteria that will guarentee uniqueness.

--
Rob Schieber


这篇关于从GUID生成20字节的int?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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