Skip to content

Instantly share code, notes, and snippets.

View PaulNichols's full-sized avatar

Paul Nichols PaulNichols

  • Australia
View GitHub Profile
@PaulNichols
PaulNichols / Program.cs
Last active December 18, 2015 06:25
Client app to call into a WebAPI secured by Azure AD
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using System;
using System.Configuration;
using System.Globalization;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
namespace ApiAuthClient
{
Configuration DevMachine
{
Import-DscResource -ModuleName PSDesiredStateConfiguration
Import-DscResource -ModuleName cChoco
Node 'Dev'
{
#Set-NetConnectionProfile -InterfaceIndex <index number> -NetworkCategory Private
#set-DscLocalConfigurationManager
#winrm quickconfig -quiet
@PaulNichols
PaulNichols / devtest.json
Last active February 15, 2021 09:39
Deployment script to create a dev test lab environment
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"labName": {
"type": "string",
"metadata": {
"description": "The name of the new lab instance to be created"
}
},
@PaulNichols
PaulNichols / Choco
Last active September 14, 2018 04:42
Choco
choco feature enable --name allowGlobalConfirmation
cinst <pkg|packages.config>
@PaulNichols
PaulNichols / HMAC.cs
Created January 9, 2017 04:54
Cryptography - hash message authentication code (HMAC)
using System.Security.Cryptography;
namespace CryptographyInDotNet
{
public class Hmac
{
private const int KeySize = 32;
public static byte[] GenerateKey()
{
@PaulNichols
PaulNichols / HashData
Created January 9, 2017 04:56
Cryptography - Hash
using System.Security.Cryptography;
namespace CryptographyInDotNet
{
public class HashData
{
public static byte[] ComputeHashSha1(byte[] toBeHashed)
{
using (var sha1 = SHA1.Create())
{
@PaulNichols
PaulNichols / Program.cs
Last active June 16, 2017 02:17
Cryptography - Hash
using System;
using System.Text;
namespace CryptographyInDotNet
{
class Program
{
static void Main()
{
const string password = "V3ryC0mpl3xP455w0rd";
@PaulNichols
PaulNichols / Pbkdf2.cs
Created January 9, 2017 23:06
Cryptography - Password Based Key Derivation Function Demonstration
using System.Security.Cryptography;
namespace CryptographyInDotNet
{
public class Pbkdf2
{
public static byte[] GenerateSalt()
{
using (var randomNumberGenerator = new RNGCryptoServiceProvider())
{
@PaulNichols
PaulNichols / AesEncryption.cs
Last active March 1, 2017 22:38
Cryptography - AES Encyption
using System.IO;
using System.Security.Cryptography;
namespace CryptographyInDotNet
{
public class AesEncryption
{
public byte[] GenerateRandomNumber(int length)
{
using (var randomNumberGenerator = new RNGCryptoServiceProvider())
using System.Security.Cryptography;
namespace CryptographyInDotNet
{
public class DigitalSignature
{
private RSAParameters _publicKey;
private RSAParameters _privateKey;
public void AssignNewKey()