directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ole Ersoy <ole.er...@gmail.com>
Subject [DAS] Generating OIDs
Date Fri, 13 Apr 2007 22:07:22 GMT
Hey Guys,

I've been experimenting with Alex's (Checksum) and Emmanuel's (Hashcode)
OID generation suggestions.

One way to do it would be to generate a SHA-1 digest.

So for:
org.apache.tuscany.das.ldap.DASConfig

We would get:
8f992f6d6fae75e72f3d3c47adc8fa641a6be82

Then we could just replace the letters with a corresponding
integer.

Does anyone know whether this will always produce alphabetical letters
numbers though?

The code I have creates the checksum like this:

MessageDigest messageDigest = MessageDigest.getInstance("SHA-1");
String checksumInput      = "org.apache.tuscany.das.ldap.DASConfig";
byte[] digest             = messageDigest.digest(checksumInput.getBytes());

StringBuffer hexString = new StringBuffer();
for (int i=0;i<digest.length;i++) {
   hexString.append (
     Integer.toHexString(0xFF & digest[i]));
   //hexString.append (" ");
}


Then there's Emmanuel's way which works like this:

String[] test = "org.apache.tuscany.das.ldap.DASConfig".split( "[.]" );
String final  = "";
for (int i=0;i<test.length;i++)
{
    String hash = StringUtils.replace(test[i], "-", "1");
    //We replace "-" with "1".
    final = final + hash;
}

This will give the id:

1103081141151710619648937659922233166471638106712

I'd probably go with this one since it's simpler to just replace
a "-" than letters...

Thoughts?

Thanks,
- Ole









Mime
View raw message