Skip to content

Instantly share code, notes, and snippets.

Paul Mowat paulmowat

Block or report user

Report or block paulmowat

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@vlucas
vlucas / encryption.js
Last active Dec 13, 2019
Stronger Encryption and Decryption in Node.js
View encryption.js
'use strict';
const crypto = require('crypto');
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bits (32 characters)
const IV_LENGTH = 16; // For AES, this is always 16
function encrypt(text) {
let iv = crypto.randomBytes(IV_LENGTH);
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv);
@markthiessen
markthiessen / GetWeeksInMonth.js
Created Oct 13, 2012
JavaScript - get weeks in a month as array of start and end days
View GetWeeksInMonth.js
//note: month is 0 based, just like Dates in js
function getWeeksInMonth(month, year){
var weeks=[],
firstDate=new Date(year, month, 1),
lastDate=new Date(year, month+1, 0),
numDays= lastDate.getDate();
var start=1;
var end=7-firstDate.getDay();
while(start<=numDays){
You can’t perform that action at this time.