Skip to content

Instantly share code, notes, and snippets.

@therightstuff
therightstuff / _end-to-end-enc.js.md
Last active December 19, 2023 02:17
Javascript / Node.js end-to-end encryption
@therightstuff
therightstuff / RSAKeys.cs
Last active November 3, 2023 16:34
Import and export RSA Keys between C# and PEM format using BouncyCastle
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.OpenSsl;
using Org.BouncyCastle.Security;
using System;
using System.IO;
using System.Security.Cryptography;
namespace MyProject.Data.Encryption
{
@therightstuff
therightstuff / RSA.cs
Last active January 31, 2024 15:13
Simple RSA Encryption, Decryption, signing and signature verification using Base64 encoded strings in C#
using System;
using System.Security.Cryptography;
using System.Text;
namespace MyProject.Data.Encryption
{
/* Encryption, decryption, signing and signature verification that's compatible with
* simple-free-encryption-tool
*/
public class RSA
@therightstuff
therightstuff / JSON-CSV.html
Last active February 21, 2019 10:51
Online JSON / CSV Converter
<html>
<head>
<title>Online JSON / CSV Converter</title>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://fastcdn.org/FileSaver.js/1.1.20151003/FileSaver.js"></script>
<script language="javascript">
var conversionStyle;
var prefixConnector;
var delimiter, delimiterCharacter;
@therightstuff
therightstuff / Program.cs
Created November 19, 2017 15:34
‘How to create an Azure SQL Database programmatically’ with less frustration
/****************************** Module Header ******************************\
* DOWNLOADED FROM https://code.msdn.microsoft.com/How-to-create-an-Azure-SQL-dbd0bf6a
* Modified By: Adam Fisher (https://github.com/therightstuff)
* Module Name: Program.cs
* Project: CSCreateAzureSQL
* Copyright (c) Microsoft Corporation.
*
* This sample will show how to create a SQL database on Microsoft Azure
* using C#
*
@therightstuff
therightstuff / restify_with_cors.js
Last active February 12, 2018 08:20
CORS middleware for restify
// MIDDLEWARE
// must be defined before routing configured
server.use(restify.plugins.bodyParser());
server.use(restify.plugins.queryParser());
// CORS must be first
var allowedMethods = [
"OPTIONS",
@therightstuff
therightstuff / BasicKeyVaultAuthentication.cs
Last active March 7, 2021 19:15
C# Azure Key Vault authentication using a service principal secret
// SEE http://www.industrialcuriosity.com/2018/03/azure-key-vault-in-c-for-dummies.html FOR FULL EXPLANATION
/// <summary>
/// Gets the access token
/// The parameters will be provided automatically, you don't need to understand them
/// </summary>
/// <param name="authority"> Authority </param>
/// <param name="resource"> Resource </param>
/// <param name="scope"> scope </param>
/// <returns> token </returns>
@therightstuff
therightstuff / exampleWorker.js
Created May 11, 2018 12:50
Web Worker callback design pattern
// ensure window object available
var window = self;
self.addEventListener('message', function (e) {
var payload = e.data;
var result = null;
var err = null;
switch (payload.cmd) {
case 'sampleCommand':
@therightstuff
therightstuff / inheritance.js
Created September 11, 2018 22:56
simple node.js inheritance example
var util = require("util");
// simple class
function A() {
this.self= this;
this.className = "classA";
this.myVar = "ownerA";
}
// class methods
@therightstuff
therightstuff / AES.cs
Last active April 4, 2020 21:01
Simple AES 256 CBC Encryption to and Decryption from Base64 encoded strings in C#
using System;
using System.Collections.Generic;
using System.IO;
using System.Security.Cryptography;
namespace MyProject.Data.Encryption
{
public class AES
{
// https://stackoverflow.com/a/18502617/2860309