<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
There is a simple algorithm here:<br>
<a class="moz-txt-link-freetext" href="http://en.wikipedia.org/wiki/Base64">http://en.wikipedia.org/wiki/Base64</a><br>
<br>
My PHP is a bit too rusty to comment on the correctness of your code.<br>
<br>
Basically Base64 works, by encoding each 6 bits into a character.<br>
That means it produces 4 bytes per 3 input bytes, and always pads up
with =, to produce a string of a length divisible by 4.<br>
I _think_ the strings ID columns are encoded as an UTF-8 byte array
into Base64.<br>
<pre class="moz-signature" cols="72">Regards, Kenneth, GEOGRAF A/S
</pre>
<br>
<br>
nclayton skrev:
<blockquote cite="mid:14739683.post@talk.nabble.com" type="cite">
  <pre wrap="">I have created this function in php which gives me the correct value for
33181 ("nYEAAA==") but I would like for another pair of eyes (or 20) to see
if this is solid and if it can be simplified.

function MgBase64_encode($value){
        $key="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
        $dhv = dechex($value);
        $grp = (strlen($dhv) / 2);
        $arr = array();
        for($i=0;$i&lt;$grp;$i++){
                $arr[$i] = substr($dhv,($i * 2),2);
        }
        $arr = array_reverse($arr);
        $bvl = decbin(hexdec(join("",$arr)));
        $chk = (strlen($bvl) % 6);
        if($chk &gt; 0){ $bvl = str_pad($bvl,(strlen($bvl) + (6 - $chk)),'0'); }
        $grp = (strlen($bvl) / 6);
        $arr = array();
        for($i=0;$i&lt;$grp;$i++){
                $arr[$i] = substr($key,bindec(substr($bvl,($i * 6),6)),1);                
        }

        return str_pad(join("",$arr),6,'A') . "==";
}


Nick




nclayton wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">Thank you for the reply and the link. I'd actually read that post, but it
gave me a bit of a headache trying to reverse the process...I'm rather new
to this mode of thinking (i avoided it as long as i could).

As far as the parcel number value is concerned, it needs to be a string
because they are different for each county that we deal with and are
typically 14-22 alphanumeric characters in length, such as
'1-023B-001.000'

Nick


JasonBirch wrote:
    </pre>
    <blockquote type="cite">
      <pre wrap="">More details on this here:

<a class="moz-txt-link-freetext" href="http://tinyurl.com/2rrq3e">http://tinyurl.com/2rrq3e</a>

I'm definitely a bit rusty on this stuff, but in your initial problem
are you sure you want to be using a string value for the parcel id?

Jason

-----Original Message-----
From: nclayton
Subject: Re: [mapguide-users] Issues selecting a feature with custom
coding

Here are the results of both the mgos base64 value and the php
base64_encode
value:

Actual FeatId: 33181
MGOS Value: nYEAAA==
base64_encode Value: MzMxODE=

I found code for writing a base64 function in javascript, and it gives
the same result as the php function.
_______________________________________________
mapguide-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:mapguide-users@lists.osgeo.org">mapguide-users@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/mapguide-users">http://lists.osgeo.org/mailman/listinfo/mapguide-users</a>


      </pre>
    </blockquote>
    <pre wrap="">
    </pre>
  </blockquote>
  <pre wrap=""><!---->
  </pre>
</blockquote>
</body>
</html>