Skip to content

Instantly share code, notes, and snippets.

View jmdemorais's full-sized avatar
🪐

José Morais jmdemorais

🪐
View GitHub Profile
@rpivo
rpivo / index.md
Last active November 24, 2024 10:23
Encrypting & Decrypting Sensitive Data With the Web Crypto API

Encrypting & Decrypting Sensitive Data With the Web Crypto API

Chris Veness created a really great gist that shares code to encrypt and decrypt data using the Web Crypto API here.

This gist breaks down the code in that gist step by step, detailing a real-world scenario with actual data.

It might be helpful to have that gist open in another tab and use this gist to walk through each line of code.

One interesting use case for this would be to encrypt on a client, and then decrypt in the cloud with something like a Lambda function. In order to do this, you could use Node's latest version as of this gist, version 15, which includes a webcrypto module that's designed to be a Node implementation of the Web Crypto API. Lambdas can't use v15 by default -- however, you can create a custom Lambda layer that contains v15.

@kascote
kascote / spinner.dart
Created July 11, 2019 16:45
flutter icon spinner
//
// https://stackoverflow.com/questions/55431496/font-awesome-spinners-icons-not-spinning-in-flutter
//
// Usage:
// Spinner(
// icon: FontAwesomeIcons.spinner,
// )
//
class Spinner extends StatefulWidget {
final IconData icon;
@jeffochoa
jeffochoa / Response.php
Last active March 11, 2025 20:15
Laravel HTTP status code
<?php
// This can be found in the Symfony\Component\HttpFoundation\Response class
const HTTP_CONTINUE = 100;
const HTTP_SWITCHING_PROTOCOLS = 101;
const HTTP_PROCESSING = 102; // RFC2518
const HTTP_OK = 200;
const HTTP_CREATED = 201;
const HTTP_ACCEPTED = 202;
@chrisveness
chrisveness / crypto-aes-gcm.js
Last active March 14, 2025 21:33
Uses the SubtleCrypto interface of the Web Cryptography API to encrypt and decrypt text using AES-GCM (AES Galois counter mode).
/**
* Encrypts plaintext using AES-GCM with supplied password, for decryption with aesGcmDecrypt().
* (c) Chris Veness MIT Licence
*
* @param {String} plaintext - Plaintext to be encrypted.
* @param {String} password - Password to use to encrypt plaintext.
* @returns {String} Encrypted ciphertext.
*
* @example
* const ciphertext = await aesGcmEncrypt('my secret text', 'pw');
@trusktr
trusktr / DefaultKeyBinding.dict
Last active March 10, 2025 06:52
My DefaultKeyBinding.dict for Mac OS X
/* ~/Library/KeyBindings/DefaultKeyBinding.Dict
This file remaps the key bindings of a single user on Mac OS X 10.5 to more
closely match default behavior on Windows systems. This makes the Command key
behave like Windows Control key. To use Control instead of Command, either swap
Control and Command in Apple->System Preferences->Keyboard->Modifier Keys...
or replace @ with ^ in this file.
Here is a rough cheatsheet for syntax.
Key Modifiers
@michelbrito
michelbrito / estados
Created January 24, 2011 06:43
Lista de Estados Brasileiros
AC|Acre
AL|Alagoas
AP|Amapá
AM|Amazonas
BA|Bahia
CE|Ceará
DF|Distrito Federal
ES|Espírito Santo
GO|Goiás
MA|Maranhão