如何合并两个GUID值 [英] How to Combine Two GUID Values

查看:73
本文介绍了如何合并两个GUID值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想结合两个Guid值并生成一个32位的字母数字值(可以通过使用散列来完成).

I want to combine two guid values and generate a 32 bit alphanumberic value(It can be done by using hashing).

推荐答案

不漂亮,但是可以..

 private static Guid MungeTwoGuids(Guid guid1, Guid guid2)
 {
     const int BYTECOUNT = 16;
     byte[] destByte = new byte[BYTECOUNT];
     byte[] guid1Byte = guid1.ToByteArray();
     byte[] guid2Byte = guid2.ToByteArray();
     
     for (int i = 0; i < BYTECOUNT; i++)
     {
         destByte[i] = (byte) (guid1Byte[i] ^ guid2Byte[i]);
     }
      return new Guid(destByte);
 }

是的,在我的情况下,我可以处理非唯一担保人

and yes, I can deal with the non-unique-guarantee in my case

这篇关于如何合并两个GUID值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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