Last change
on this file since 31896 was 31896, checked in by vboxsync, 15 years ago |
export the VBoxUSB host driver to OSE
|
-
Property svn:eol-style
set to
native
-
Property svn:keywords
set to
Author Date Id Revision
|
File size:
1.1 KB
|
Line | |
---|
1 | /* $Id: USBLib.cpp 31896 2010-08-24 09:17:44Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox USB Library, Common Bits.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2008 Oracle Corporation
|
---|
8 | *
|
---|
9 | * Oracle Corporation confidential
|
---|
10 | * All rights reserved
|
---|
11 | */
|
---|
12 |
|
---|
13 |
|
---|
14 | /*******************************************************************************
|
---|
15 | * Header Files *
|
---|
16 | *******************************************************************************/
|
---|
17 | #include <VBox/usblib.h>
|
---|
18 |
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * Calculate the hash of the serial string.
|
---|
22 | *
|
---|
23 | * 64bit FNV1a, chosen because it is designed to hash in to a power of two
|
---|
24 | * space, and is much quicker and simpler than, say, a half MD4.
|
---|
25 | *
|
---|
26 | * @returns the hash.
|
---|
27 | * @param pszSerial The serial string.
|
---|
28 | */
|
---|
29 | USBLIB_DECL(uint64_t) USBLibHashSerial(const char *pszSerial)
|
---|
30 | {
|
---|
31 | if (!pszSerial)
|
---|
32 | pszSerial = "";
|
---|
33 |
|
---|
34 | register const uint8_t *pu8 = (const uint8_t *)pszSerial;
|
---|
35 | register uint64_t u64 = UINT64_C(14695981039346656037);
|
---|
36 | for (;;)
|
---|
37 | {
|
---|
38 | register uint8_t u8 = *pu8;
|
---|
39 | if (!u8)
|
---|
40 | break;
|
---|
41 | u64 = (u64 * UINT64_C(1099511628211)) ^ u8;
|
---|
42 | pu8++;
|
---|
43 | }
|
---|
44 |
|
---|
45 | return u64;
|
---|
46 | }
|
---|
47 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.