Skip to content

Instantly share code, notes, and snippets.

View szarapka's full-sized avatar
:atom:
Operating at 1.21 gigawatts

Scott Szarapka szarapka

:atom:
Operating at 1.21 gigawatts
View GitHub Profile

Keybase proof

I hereby claim:

  • I am szarapka on github.
  • I am szarapka (https://keybase.io/szarapka) on keybase.
  • I have a public key whose fingerprint is 7DD0 0EC0 5C6A BB3E 1687 9B8B A561 9050 076C 201E

To claim this, I am signing this object:

@szarapka
szarapka / mongoose-encrypted-schematype-field.md
Created December 5, 2015 00:34 — forked from kljensen/mongoose-encrypted-schematype-field.md
Encrypt a text field in Mongoose MongoDB ORM

Encrypting text fields in Mongoose is easy using Node's built-in crypto module. You might want to do this if you're using MongoDB as a service (see the recent MongoHQ security breach); or, if you're storing OAuth tokens that could, in the wrong hands, screw with somebody's account on a 3rd party service. (Of course, you should never encrypt passwords: those should be hashed.)

Imagine you have a Mongoose model like that shown below, which is modified only slighly from the example on the MongooseJS homepage.

var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test');

var User = mongoose.model('User', {
 name: String,
Verifying that +szarapka is my blockchain ID. https://onename.com/szarapka