Skip to content

Instantly share code, notes, and snippets.

@miguelmota
miguelmota / KmsSigner.js
Last active January 11, 2023 15:26
JavaScript ethers Signer using AWS KMS
const { BigNumber, Signer } = require('ethers')
const { keccak256, recoverAddress, joinSignature, resolveProperties, serializeTransaction, hashMessage, arrayify, defineReadOnly } = require('ethers/lib/utils')
const { KMSClient, GetPublicKeyCommand, SignCommand } = require('@aws-sdk/client-kms')
const asn1 = require('asn1.js')
const EcdsaPubKey = asn1.define('EcdsaPubKey', function () {
this.seq().obj(
this.key('algo').seq().obj(
this.key('a').objid(),
this.key('b').objid()
@mxmauro
mxmauro / adding-gpg-keys.md
Created March 9, 2022 11:48
How to sign git tags and commits

How to sign git tags and commits

The following step-by-step guide will assist you to start pushing signed commits and create signed tags. This is a quick-start guide. For more details, you can visit here and here.

There some topics to take into account on why we decided to follow a specific approach on certificate management:

  • GitHub does not handle master certificates revocation but the community seems to not care about this because the purpose of these certificates is to demostrate to others that you are you and not other person impersonating you. If your certificate expires or is stolen, you simply create a new one and upload it to GitHub. Because GitHub also verifies the email address, a thief must also gain to your account in order to be able to use it.
  • Using subkeys is preferable but updating them and GitHub periodically can become a pa
@statik
statik / waf.ts
Last active October 16, 2024 02:36
WAF with CDK examples
import * as cdk from "@aws-cdk/core";
import * as wafv2 from "@aws-cdk/aws-wafv2";
// This extends the base cdk stack properties to include a tag name input.
export interface StackProps extends cdk.StackProps {
tag: string;
applicationName?: string;
}
export class WAFStack extends cdk.Stack {
@cocowalla
cocowalla / Ecies.cs
Last active June 22, 2024 14:07
Simple ECIES implementation
using System;
using System.Security.Cryptography;
// ReSharper disable SuggestVarOrType_SimpleTypes - BCL rules
namespace Crypto
{
/// <summary>
/// Simple implementation of ECIES (Elliptic Curve Integrated Encryption Scheme) based on http://www.secg.org/sec1-v2.pdf, section 5.1
/// Things not implemented:
/// - Encoding parameters using compressed points; only uncompressed points are used
@ChaoLiangSuper
ChaoLiangSuper / encryption.ts
Last active March 24, 2024 14:30 — forked from vlucas/encryption.js
Stronger Encryption and Decryption in typescript
import crypto from 'crypto';
const ALGORITHM = 'aes-256-cbc';
const ENCODING = 'hex';
const IV_LENGTH = 16;
const KEY = process.env.ENCRYPTION_KEY!;
export const encrypt = (data: string) => {
const iv = crypto.randomBytes(IV_LENGTH);
const cipher = crypto.createCipheriv(ALGORITHM, new Buffer(KEY), iv);
@JaimeStill
JaimeStill / README.md
Last active November 7, 2024 16:14
ASP.NET Core Active Directory Integration

Active Directory Authentication

This will provide an example of integrating Active Directory authentication in an ASP.NET Core app.

Note, you'll need to be running on a Windows domain with Visual Studio debugging in IIS Express for this to work.

Setup

In launchSettings.json, you'll want to modify iisSettings by turning on windowsAuthentication:

@ksaitor
ksaitor / ethereum-payment-metamask.html
Last active November 4, 2024 15:18
How to add Ethereum payments to your site with MetaMask
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<div>
<button class="pay-button">Pay</button>
<div id="status"></div>
</div>
import { Injectable } from '@angular/core';
import * as firebase from 'firebase/app';
import { AngularFirestore, AngularFirestoreDocument, AngularFirestoreCollection } from 'angularfire2/firestore';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/take';
import 'rxjs/add/operator/toPromise';
import 'rxjs/add/operator/switchMap';
@dschep
dschep / raspbian-python3.6.rst
Last active November 14, 2024 11:22 — forked from BMeu/raspbian-python3.5.rst
Installing Python 3.6 on Raspbian

Installing Python 3.6 on Raspbian

As of January 2018, Raspbian does not yet include the latest Python release, Python 3.6. This means we will have to build it ourselves, and here is how to do it. There is also an ansible role attached that automates it all for you.

  1. Install the required build-tools (some might already be installed on your system).