Generate a random API key on initial setup (fixes #1118)

Also makes the javascript implementation use the same algorithm for
generating random strings.
Merge pull request #1147 from syncthing/fix-1118

Generate a random API key on initial setup (fixes #1118)