views:

46

answers:

1

Hi,

I need to scramble Device IDs on the Blackberry for privacy matter. When I call the function DeviceInfo.getDeviceId() I got a 9 characters number. After convert it in Hexa, I got the real PIN number for the device (or device ID depends how you call that) on 8 characters.

Like I said, for privacy matter I can't store the PIN as is in my database. So I would like to scramble the ID to a unique one, still in 8 characters. If I do MD5 or other encryption, I always got an number containing more than 8 characters.

Do you know a way to get a unique 8 characters string from the Device ID? Thank you.

+1  A: 

You can use a short block cipher to obsfucate the message. Look at the CBC-MAC mode of operation.

As the output you want is actually only 4 bytes long, you could even use a CRC, such as CRC32.

Note that you would need a "perfect hash" to not have an overlap - neither short key CBC-MAC or CRC32 will give you a perfect hash. I would strongly suggest using a longer hash function.

Yann Ramin
Basically you're telling me to use another encryption method like SHA or MD5 for example?I just asked my question because I store the device ID in my database with a 8 characters string and can't modify the database. So I need to have 8 characters scrambled device IDs.I was first taking the result on 9 characters from DeviceInfo.getDeviceId(), get the substring from 0 to 8 and insert it into my database so that I can't retrieve the device ID (because of 1 character missing). But the uniqueness of this 8 characters number is not 100% sure then.
Dachmt