This is the function that my prison cells use to generate semi-unique prisoner ID numbers that are permanent for each avatar. I am releasing this code to make it easy for other creators & people running roleplay locations to generate matching prisoner IDs across multiple systems.

Feel free to make the code more efficient and/or adapt it to your needs, all I am asking is that you do not modify how IDs are generated, to keep everything compatible.

string GeneratePrisonerID(key kUUID)
{
    integer legacy = llSubStringIndex(llGetUsername(kUUID),".") != -1;
    string sRaw = llSHA1String(kUUID);

    if(legacy) //SDDDD
    {
        integer iChar = (integer)("0x"+llGetSubString(sRaw,1,4)) % 26;
        string sResult = llGetSubString("ABCDEFGHIJKLMNOPQRSTUVWXYZ",iChar,iChar);
        return sResult + llGetSubString((string)((integer)("0x"+llGetSubString(sRaw,9,13)) + 10000),1,4);
    }
    else //DDDDD
        return llGetSubString((string)((integer)("0x"+llGetSubString(sRaw,0,4)) + 100000),1,5);
}