Skip to content

Instantly share code, notes, and snippets.

View abcdabcd987's full-sized avatar
😄
( ´ ▽ ` )ノ

Lequn Chen abcdabcd987

😄
( ´ ▽ ` )ノ
View GitHub Profile
@abcdabcd987
abcdabcd987 / calc_password.js
Created September 25, 2015 06:59
using pbkdf2 to hash password (node.js)
// See: http://stackoverflow.com/questions/17218089/salt-and-hash-using-pbkdf2
// See: https://crackstation.net/hashing-security.htm
'use strict';
let Promise = require('bluebird');
let crypto = require('crypto');
function calcPassword(password) {
const RANDOM_BYTES = 64;
#include <vector>
/**
Given an non-decreasing ordered array `arr`, search the biggest `i` that makes `arr[i] == value`.
If `i` doesn't exist, return -1
*/
int search_last_match(const std::vector<int>& arr, const int value)
{
int lef = 0, rig = static_cast<int>(arr.size());
while (rig-lef > 1)
/*
* GET message listing => show()
* POST meaasge posting => send()
*/
var settings = require('../settings');
var group = require('../models/group');
var mesg = require('../models/mesg');
var md = require('markdown').markdown.toHTML;