Skip to content

Instantly share code, notes, and snippets.

@langjinet
langjinet / RSAKeys.cs
Created July 28, 2021 04:47 — forked from therightstuff/RSAKeys.cs
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
{
@langjinet
langjinet / getMax.js
Last active September 20, 2017 02:50
function declare example, can use Mocha to test and also work with browser
(function( factory ) {
"use strict";
if ( typeof exports === 'object' ) {
// learn how to inject/load other module like jQuery to this module
/*module.exports = function (root, $) {
if ( ! root ) {
// CommonJS environments without a window global must pass a
// root. This will give an error otherwise
root = window;
}
@langjinet
langjinet / Word.FindAndReplace.cs
Last active August 20, 2017 11:19
Find and replace with Open XML SDK
public static void SearchAndReplace(string document, string outDocument)
{
string docText = null;
// copy doc
System.IO.File.Copy(document, outDocument);
using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(outDocument, true))
{
using (StreamReader sr = new StreamReader(wordDoc.MainDocumentPart.GetStream()))