edited

Note that PHP's chr wraps negative numbers properly. Not all languages will do this. You may need ($c+256-$s)%256. To test for that you should see if whatever you're using for chr produces the same for 0 - s as 256 - s.

If you're encoding your own password (generating conf)...

php -r 'echo bin2hex("Sweet as a corn that'\''s not yet born."), 0;'

There's no point to bother shifting it. Shifting and hex encoding is so weak it might as well be plain text.