This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Security.Cryptography; | |
namespace Cryptography | |
{ | |
public class RSA | |
{ | |
public static string Encrypt(string text, string key) | |
{ | |
Throw.IfIsNullOrEmpty(text); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class OAuthTokenUtility { | |
private readonly RSACryptoServiceProvider _PublicProvider; | |
private readonly RSACryptoServiceProvider _PrivateProvider; | |
public OAuthTokenUtility(X509Certificate2 certificate) { | |
_PublicProvider = (RSACryptoServiceProvider)certificate.PublicKey.Key; | |
_PrivateProvider = (RSACryptoServiceProvider)Certificate.PrivateKey; | |
} | |
public string Token(string username, double numberOfMinutesToExpireIn, IEnumerable<string> tokens) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Security.Cryptography; | |
using System.Security.Cryptography.X509Certificates; | |
namespace DigitalSigning | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using APSP.Form.Model; | |
using NHibernateRepository; | |
using NUnit.Framework; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Security.Cryptography; | |
using System.Text; | |
namespace APSPTest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace EncryptionWithCertificate | |
{ | |
using System; | |
using System.Security.Cryptography; | |
using System.Security.Cryptography.X509Certificates; | |
using System.Text; | |
class Program | |
{ | |
//// makecert -pe MyCryptCert.cer -ss my -n "CN=Frans2" -sky exchange -r |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Security.Cryptography; | |
using System.Security.Cryptography.X509Certificates; | |
namespace CryptoPlayground.StrongNameKeyManagement | |
{ | |
public class StrongNameKeyManager | |
{ | |
public StrongNameKeyManager(string containerName, bool machineScope = true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Security.Cryptography; | |
using System.IO; | |
namespace ConsoleTester |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// signature | |
var signature = headerEncoded + "." + claimEncoded; | |
var signatureBytes = Encoding.UTF8.GetBytes(signature); | |
var certificate = new X509Certificate2(privateKey, privateKeyPassword); | |
// sign signature using SHA256 with RSA | |
var rsa = (RSACryptoServiceProvider)certificate.PrivateKey; | |
// As of .NET 3.5 SP1 the CSP instance works with a provider of type PROV_RSA_AES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//********************************************************************************** | |
// | |
//OpenSSLKey | |
// .NET 2.0 OpenSSL Public & Private Key Parser | |
// | |
// Copyright (C) 2008 JavaScience Consulting | |
// | |
//*********************************************************************************** | |
// | |
// opensslkey.cs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Security.Cryptography; | |
namespace SomeProgram | |
{ | |
static class Program | |
{ | |
static void Main() | |
{ | |
using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(KEY_SIZE)) |
OlderNewer