The four digits used to encode each character are chosen according to the "shape" of the four corners of each character, i.e. the upper left, upper right, lower left and lower right corners.
There have been scores, maybe hundreds, of such numerical and alpha-numerical systems proposed or popularized (such as Lin Yutang's "Instant Index", Trindex, Head-tail, Wang An's Sanjiahaoma, Halpern); some Chinese refer to these generically as "sijiaohaoma" (after the original pamphlet) though this is not correct.