def serialToIntermediaryPid(s, l)
			crc = crc32(s)  
			arr1 = Array.new(l, 0)
			for i in 0..(s.length - 1) do
				code = s[i]
				code = code.ord if code.class == String # Fix for Ruby 1.9+
				arr1[i%l] ^= code
			end

			# Grab each CRC byte and OR with a portion of the 
			crc_bytes = [crc >> 24 & 0xff, crc >> 16 & 0xff, crc >> 8 & 0xff, crc & 0xff]
			for i in 0..(l - 1) do
				arr1[i] ^= crc_bytes[i&3]
			end

			pid = ""
			for i in 0..(l-1) do
				b = arr1[i] & 0xff
				pid += LETTERS[(b >> 7) + ((b >> 5 & 3) ^ (b & 0x1f))]
			end
			pid
		end
def serialToIntermediaryPid(s, l)
			crc = crc32(s)  
			arr1 = Array.new(l, 0)
			for i in 0..(s.length - 1) do
				code = s[i]
				code = code.ord if code.class == String # Fix for Ruby 1.9+
				arr1[i%l] ^= code
			end

			# Grab each CRC byte and OR with a portion of the 
			crc_bytes = [crc >> 24 & 0xff, crc >> 16 & 0xff, crc >> 8 & 0xff, crc & 0xff]
			for i in 0..(l - 1) do
				arr1[i] ^= crc_bytes[i&3]
			end

			pid = ""
			for i in 0..(l-1) do
				b = arr1[i] & 0xff
				pid += LETTERS[(b >> 7) + ((b >> 5 & 3) ^ (b & 0x1f))]
			end
			pid
		end
Figures out the intermediary Personal ID (PID) of a device based on its
 serial number and expected length of the output. Apparently this
 varies by the type of device.