Re-hash passwords from an old platform on the fly

Installs: 332

Dependents: 0

Suggesters: 0

Security: 0

Stars: 6

Watchers: 1

Forks: 2

Open Issues: 0


0.5.0 2020-05-03 23:00 UTC

This package is auto-updated.

Last update: 2020-09-03 23:47:12 UTC


Build status MIT license Latest Stable Version Total Downloads Donate

This extension allows your users to continue to login with their passwords from a previous platform that was using a different hashing algorithm than Flarum.


This extension requires PHP7 or above

Use Bazaar or install manually:

composer require migratetoflarum/old-passwords


composer update migratetoflarum/old-passwords
php flarum migrate
php flarum cache:clear


This extension is meant to be used alongside a migration script. There are no settings accessible from the UI (you still need to keep the extension enabled for it to work !)

The migrations add a migratetoflarum_old_password column to your users table, which can contain old credentials hashed with different algorithms than bcrypt.

This column must contain a valid JSON-serialized object as described below or null to not provide an old password.

Once a user was correctly identified via an old password, the password is re-hashed with bcrypt, stored in Flarum password field and the migratetoflarum_old_password column is set to null.

If you somehow manage to have both a bcrypt-hashed password and migratetoflarum_old_password value in the database for a user, then the user will be able to login with either password. The password used will override the value of password and migratetoflarum_old_password will be set to null.

Compatible hashings

Don't hesitate to open an issue or a PR to suggest a new hashing method. More will be added soon.

While some of these options might be convenient for testing purposes or other shenanigans, some can put your old password's users at risk in case of a breach. These options are labelled with /!\ Insecure. Just as the whole extension, use these at your own risks !


/!\ Insecure: you can directly salt and hash plain text passwords with bcrypt and store them in password instead.




It probably doesn't make sense to store a bcrypt hash here instead of the password column, but it is possible.

Example (password = bcrypt(correcthorsebatterystaple)):



Reads portable and bcrypt hashes created with Phpass.

In order to use this type you need to install the hautelook/phpass package:

composer require hautelook/phpass:^1.1

Example (password = portablehash(correcthorsebatterystaple)):



/!\ Insecure: with or without a salt MD5 stays weak. Consider using the md5-bcrypt option below.

Example (password = md5(correcthorsebatterystaple)):


Example with salt before the password (password = md5(12345678correcthorsebatterystaple)):


Example with salt after the password (password = md5(correcthorsebatterystaple12345678)):



This is the preferred method to import MD5 hashes. You have to run every old MD5 password hash through bcrypt and store the resulting value in Flarum.

Example (password = bcrypt(md5(correcthorsebatterystaple))):


Example (password = bcrypt(md5(12345678correcthorsebatterystaple))):


You can use salts the same way as described for MD5.


/!\ Insecure: consider using the md5-double-bcrypt option below.

Same as MD5, but the password is hashed a first time before the salt is added.

Example (password = md5(12345678 + md5(correcthorsebatterystaple))):


You can use salts the same way as described for MD5.


Same as MD5-Double, with an extra bcrypt layer.

Example (password = bcrypt(md5(12345678 + md5(correcthorsebatterystaple)))):



/!\ Insecure: with or without a salt SHA1 stays weak. Consider using the sha1-bcrypt option below.

Example (password = sha1(correcthorsebatterystaple)):


You can use salts the same way as described for MD5.


This is the preferred method to import SHA1 hashes. You have to run every old SHA1 password hash through bcrypt and store the resulting value in Flarum.

Example (password = bcrypt(sha1(correcthorsebatterystaple))):


You can use salts the same way as described for MD5.


/!\ Insecure: consider using the sha1-double-bcrypt option below.

Same as md5-double for sha1.

Example (password = sha1(12345678 + sha1(correcthorsebatterystaple))):



Same as md5-double-bcrypt for sha1.

Example (password = bcrypt(sha1(12345678 + sha1(correcthorsebatterystaple)))):



MD5-based hash used by Unclassified NewsBoard.

Example (password = first16bytes(md5(correcthorsebatterystaple)) + 12 + last16bytes(md5(correcthorsebatterystaple))):


A MigrateToFlarum extension

This is a free extension by MigrateToFlarum, an online forum migration tool (launching soon). Follow us on Twitter for updates https://twitter.com/MigrateToFlarum

Need a custom Flarum extension ? Contact Clark Winkelmann !