You still haven’t said what problem you’re trying to solve. Can you say more about what MD 5 is solving?
You still need to implement whatever changes you make on a plugin. Have you started to learn how plugins work?
But I bet what you really want is to have discourse authenticate against your existing app, in case you just need to implement discourse_connect and discourse won’t need to know about your choices in password storage.