wiki.techinc.nl/includes/resourceloader
Ori Livneh dfd046412f resourceloader: Replace SHA1 with 32-bit FNV-1 as hash function
SHA-1 is not secure enough to be used as a cryptographic hash function, and its
implementation in JavaScript is too long and too slow for it to be a good
general-purpose hash function. And we currently throw away most of the work:
SHA-1 produces 160-bit hash values, of which we keep 48.

Although the JavaScript implementation is not exported, SHA-1 is a well-known
hash function, and I'm willing to bet that sooner or later someone will move to
make it accessible to other modules, at which point usage will start to spread.

For ResourceLoader, the qualities we're looking for in a hash function are:

* Already implemented in PHP
* Easy to implement in JavaScript
* Fast
* Collision-resistant

The requirement that hashes be cheap to compute in JavaScript narrows the field
to 32-bit hash functions, because in JavaScript bitwise operators treat their
operands as 32 bits, and arithmetic uses double-precision floats, which have a
total precision of 53 bits. It's possible to work around these limitations, but
it's a lot of extra work.

The best match I found is the 32-bit variant of FNV-1, which is available in
PHP as of version 5.4 (as 'fnv1a32'). The fnv132 JavaScript function is
around ten times faster and eight times shorter than sha1.

Change-Id: I1e4fb08d17948538d96f241b2464d594fdc14578
2016-07-05 21:14:03 +00:00
..
DerivativeResourceLoaderContext.php
ResourceLoader.php resourceloader: Replace SHA1 with 32-bit FNV-1 as hash function 2016-07-05 21:14:03 +00:00
ResourceLoaderContext.php resourceloader: Remove false return from Context::getUserObj() 2016-05-10 20:39:56 +01:00
ResourceLoaderEditToolbarModule.php
ResourceLoaderFileModule.php resourceloader: Strip leading BOM when concatenating files 2016-05-31 19:47:19 +01:00
ResourceLoaderFilePath.php
ResourceLoaderForeignApiModule.php
ResourceLoaderImage.php resourceloader: Remove wfExpandUrl() from ResourceLoaderImage 2016-04-02 00:25:11 +01:00
ResourceLoaderImageModule.php
ResourceLoaderJqueryMsgModule.php
ResourceLoaderLanguageDataModule.php
ResourceLoaderLanguageNamesModule.php
ResourceLoaderModule.php resourceloader: Remove unused Module::setOrigin() method 2016-05-10 19:13:33 +01:00
ResourceLoaderOOUIImageModule.php
ResourceLoaderRawFileModule.php Always use 'bool' instead of 'boolean' in Doxygen tags 2016-03-24 09:44:09 +01:00
ResourceLoaderSiteModule.php
ResourceLoaderSiteStylesModule.php resourceloader: Create 'site.styles' module 2016-06-15 23:06:50 -07:00
ResourceLoaderSkinModule.php Fix and standardize Doxygen tags 2016-04-30 12:10:17 +02:00
ResourceLoaderSpecialCharacterDataModule.php Follow-up Idb1202579: Add special-characters-group-greekextended to RL module 2016-04-14 19:50:10 +01:00
ResourceLoaderStartUpModule.php resourceloader: Avoid Title::newMainPage() to support $wgForceUIMsgAsContentMsg 2016-04-01 23:37:09 +00:00
ResourceLoaderUploadDialogModule.php Refactor upload dialog to make it configurable 2016-05-16 21:14:58 +02:00
ResourceLoaderUserCSSPrefsModule.php
ResourceLoaderUserDefaultsModule.php
ResourceLoaderUserModule.php resourceloader: Merge 'user.groups' into 'user' module 2016-05-26 04:15:33 +00:00
ResourceLoaderUserOptionsModule.php
ResourceLoaderUserTokensModule.php OutputPage: Minor clean up of <head> and HTML 2016-03-24 03:24:31 +00:00
ResourceLoaderWikiModule.php Revert "resourceloader: Add support for variables in WikiModule" 2016-06-09 19:27:34 +00:00