Why not just take telegram source code and remove the phone number authentication?
In Telegram local message database is not encrypted by default so you have to set a password. The encryption algorithm used for secret chats, MTProto, was created by the Telegram developers so there are no guarantees on the security front here.