An optical code generator having a phase code and a generation method are provided to improve the signal-to-noise ratio twice as high as that of an incoherent method and simplify the structure. An optical code generator(10) generates an optical code by mutually dividing and re-combining the input pulse in core and cladding modes by plural long-period optical fiber gratings(15a,15b,15c) separated from each other on a first core(11) along the extension direction of the first core of an optical fiber having a cladding(12) covering the first core. In addition, the optical code generator has a phase varying unit(20) formed at a region, where the first core is formed, between the long-period optical fiber gratings to vary the phase of the light progressing in a core mode.
展开▼