Password salting - MoodleDocs (2024)

Contents

  • 1 What is password salting?
  • 2 Enabling password salting
  • 3 Changing the salt
  • 4 Disabling password salting
  • 5 Importing users from another site
  • 6 How does password salting work?

What is password salting?

Passwords are stored in Moodle in an encrypted form, called an 'md5 hash'.

Password salting is a way of making passwords more secure by adding a random string of characters to passwords before their md5 hash is calculated, which makes them harder to reverse (the longer the random string, the harder you make it).

Enabling password salting

To set a password salt, add the following line to your config.php file:

$CFG->passwordsaltmain = 'some long random string here with lots of characters';

The random string of characters should be a mix of letters, numbers and other characters. The Moodle Salt Generator may be used to obtain a suitable long random string. A string length of at least 40 characters is recommended.

Note: For security reasons the only way to enable password salting is by editing config.php - there is no way to do so in the Moodle interface.

Tip: Keep a note of your password salt somewhere other than config.php to prevent the situation of your password salt being lost and all site users having to go through password recovery to reset their passwords.

Changing the salt

If for any reason you wish to change the salt, the old salt must be retained in config.php in addition to the new salt.

passwordsaltmain should be changed to passwordsaltalt1 (note that the exact expressions must be used) for the old salt as follows:

$CFG->passwordsaltalt1 = 'old long random string';$CFG->passwordsaltmain = 'new long random string';

If you change your salt again in the future, you must retain all the previous salts for some time (until every user has logged in at least once, so they start using the new salt). You can use $CFG->passwordsaltalt2, $CFG->passwordsaltalt3, etc. to keep up to 20 previous salts.

Warning: If you change the salt and do not retain the old one in config.php you will no longer be able to login to your site!

Disabling password salting

Note: Not Recommended! Once enabled, you should leave password salt enabled.

To disable password salting in Moodle, you can delete, comment out, or change the value of passwordsaltmain to "empty"

// EXAMPLE: set to empty string$CFG->passwordsaltmain = '';
// EXAMPLE: comment out/*$CFG->passwordsaltmain = '';*/

However, you are not done! You must also move the old salt to an "alt" value, just like the "changing the salt" description, above:

$CFG->passwordsaltalt1 = 'old long random string';$CFG->passwordsaltmain = '';

Importing users from another site

If you import users from another Moodle site which uses a password salt, you need to add the other site's salt to config.php too. Upto 20 alternate salts may be added

$CFG->passwordsaltalt1, $CFG->passwordsaltalt2, ... $CFG->passwordsaltalt20

How does password salting work?

When a password is checked, the code looks for CFG->passwordsaltmain. If set, salt is appended to user's password before calculating the md5 hash.

If the unsalted md5 hash of a user's password validates, it is assumed that the salt was set for the first time since the last time the user logged in. The user's password is upgraded, using the salt. The password is salted during the first login after the salt was set in config.php.

If neither the unsalted md5 hash, or the salted md5 hash validates, the code looks for up to 20 alternate salts.

If you change salts, in order not to orphan existing user accounts, you must enter the old salt into one of the alternate slots.

When a user who has an "old salt" password logs in, the first test of their authentication with the new salt will fail... then the code will test any alternate salts, looking for one that allows the password to be proven valid.

If a user is deemed valid, the system will upgrade the user's hashed password to the latest salt.

Password salting - MoodleDocs (2024)
Top Articles
Global Green Technology & Sustainability Market Forecast to 2030: Surging Demand for AI-Driven Recycling Technologies to Fuel Green Innovations and Sustainability
Disable Css Code | How to Disable Css Code?
What Is Single Sign-on (SSO)? Meaning and How It Works? | Fortinet
$4,500,000 - 645 Matanzas CT, Fort Myers Beach, FL, 33931, William Raveis Real Estate, Mortgage, and Insurance
Xre-02022
Custom Screensaver On The Non-touch Kindle 4
THE 10 BEST Women's Retreats in Germany for September 2024
Us 25 Yard Sale Map
Geodis Logistic Joliet/Topco
Gw2 Legendary Amulet
Red Heeler Dog Breed Info, Pictures, Facts, Puppy Price & FAQs
Reddit Wisconsin Badgers Leaked
Craigslist Pets Sac
Nalley Tartar Sauce
Nj State Police Private Detective Unit
The Superhuman Guide to Twitter Advanced Search: 23 Hidden Ways to Use Advanced Search for Marketing and Sales
Lonesome Valley Barber
R Personalfinance
What Is Vioc On Credit Card Statement
Kashchey Vodka
Puss In Boots: The Last Wish Showtimes Near Cinépolis Vista
Universal Stone Llc - Slab Warehouse & Fabrication
Brazos Valley Busted Newspaper
Apparent assassination attempt | Suspect never had Trump in sight, did not get off shot: Officials
Booknet.com Contract Marriage 2
Toonkor211
897 W Valley Blvd
FSA Award Package
Craigslist Scottsdale Arizona Cars
WOODSTOCK CELEBRATES 50 YEARS WITH COMPREHENSIVE 38-CD DELUXE BOXED SET | Rhino
Kelley Fliehler Wikipedia
The Transformation Of Vanessa Ray From Childhood To Blue Bloods - Looper
Smith And Wesson Nra Instructor Discount
Ksu Sturgis Library
Columbia Ms Buy Sell Trade
Linda Sublette Actress
Indiana Jones 5 Showtimes Near Cinemark Stroud Mall And Xd
Lovein Funeral Obits
Obituaries in Hagerstown, MD | The Herald-Mail
Makes A Successful Catch Maybe Crossword Clue
Best Haircut Shop Near Me
Go Nutrients Intestinal Edge Reviews
Lyons Hr Prism Login
Theater X Orange Heights Florida
Jimmy John's Near Me Open
The Cutest Photos of Enrique Iglesias and Anna Kournikova with Their Three Kids
Dlnet Deltanet
Freightliner Cascadia Clutch Replacement Cost
Morbid Ash And Annie Drew
Southwind Village, Southend Village, Southwood Village, Supervision Of Alcohol Sales In Church And Village Halls
BYU Football: Instant Observations From Blowout Win At Wyoming
Latest Posts
Article information

Author: Delena Feil

Last Updated:

Views: 6432

Rating: 4.4 / 5 (65 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Delena Feil

Birthday: 1998-08-29

Address: 747 Lubowitz Run, Sidmouth, HI 90646-5543

Phone: +99513241752844

Job: Design Supervisor

Hobby: Digital arts, Lacemaking, Air sports, Running, Scouting, Shooting, Puzzles

Introduction: My name is Delena Feil, I am a clean, splendid, calm, fancy, jolly, bright, faithful person who loves writing and wants to share my knowledge and understanding with you.