Tiny Node.js module to securely hash and compare passwords using pbkdf2 with per password random salt.
To hash a password:
var password = require('./password');
var crypto = require('crypto'); | |
// larger numbers mean better security, less | |
var config = { | |
// size of the generated hash | |
hashBytes: 32, | |
// larger salt means hashed passwords are more resistant to rainbow table, but | |
// you get diminishing returns pretty fast | |
saltBytes: 16, | |
// more iterations means an attacker has to take longer to brute force an |
'use strict'; | |
/** | |
* Javascript version of https://gist.github.com/jbroadway/2836900 | |
* | |
* Slimdown - A very basic regex-based Markdown parser. Supports the | |
* following elements (and can be extended via Slimdown::add_rule()): | |
* | |
* - Headers | |
* - Links |
Putting cryptographic primitives together is a lot like putting a jigsaw puzzle together, where all the pieces are cut exactly the same way, but there is only one correct solution. Thankfully, there are some projects out there that are working hard to make sure developers are getting it right.
The following advice comes from years of research from leading security researchers, developers, and cryptographers. This Gist was [forked from Thomas Ptacek's Gist][1] to be more readable. Additions have been added from
const publicPath = 'public'; | |
// Node os module | |
// The os module provides a number of operating system-related utility methods. | |
// It can be accessed using: | |
const os = require('os'); | |
// Using a single monolithic configuration file impacts comprehension and | |
// removes any potential for reusability. | |
// As the needs of your project grow, you have to figure out the means to manage | |
// webpack configuration more effectively. |
// we have an async "initialize" method that performs several calls consecutively. | |
// after each step in the async chain, we might have been unmounted already | |
// and performing any further calls becomes obsolete | |
class DefaultComponent extends React.Component { | |
// ... | |
componentDidMount() { | |
this._isMounted = true; | |
this.initialize(); | |
} | |
componentWillUnmount() { |
//acf stats repeater | |
array ( | |
'key' => 'field_5a27ee3a83076', | |
'label' => 'Stats', | |
'name' => 'stats', | |
'type' => 'repeater', | |
'instructions' => '', | |
'required' => 0, | |
'conditional_logic' => 0, | |
'wrapper' => array ( |
RewriteRule "(^|/)\.(?!well-known\/)" - [F] |
// Based on: https://stackoverflow.com/a/46814952/283851 | |
/** | |
* Create a Base64 Image URL, with rotation applied to compensate for EXIF orientation, if needed. | |
* | |
* Optionally resize to a smaller maximum width - to improve performance for larger image thumbnails. | |
*/ | |
export async function getImageUrl(file: File, maxWidth: number|undefined) { | |
return readOrientation(file).then(orientation => applyRotation(file, orientation || 1, maxWidth || 999999)); | |
} |