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
-- This module contains functions to calculate SHA2 digest. | |
-- Supported hashes: SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, SHA-512/256 | |
-- This is a pure-Lua module, compatible with Lua 5.1 | |
-- It works on Lua 5.1/5.2/5.3/5.4/LuaJIT, but it doesn't use benefits of Lua versions 5.2+ | |
-- Input data may must be provided either as a whole string or as a sequence of substrings (chunk-by-chunk). | |
-- Result (SHA2 digest) is a string of lowercase hex digits. | |
-- | |
-- Simplest usage example: | |
-- local your_hash = require("sha2for51").sha512("your string") |
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
#define SECURITY_WIN32 | |
#include <iostream> | |
#include <tuple> | |
#include <Windows.h> | |
#include <security.h> | |
#include <schannel.h> | |
#pragma comment(lib, "Secur32.lib") | |
static std::tuple<int, const char*> protocols[] = { | |
{ SP_PROT_PCT1_CLIENT, "PCT 1.0" }, |
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
#include <Windows.h> | |
#include <wincrypt.h> | |
#include <stdio.h> | |
#pragma comment(lib, "advapi32.lib") | |
#define AES_KEY_SIZE 16 | |
#define IN_CHUNK_SIZE (AES_KEY_SIZE * 10) // a buffer must be a multiple of the key size | |
#define OUT_CHUNK_SIZE (IN_CHUNK_SIZE * 2) // an output buffer (for encryption) must be twice as big | |
//params: <input file> <output file> <is decrypt mode> <key> |
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
setmetatable(_ENV, { __index=lpeg }) | |
Scopes = { {} } | |
function eval_expr(expr) | |
local accum = eval(expr[2]) -- because 1 is "expr" | |
for i = 3, #expr, 2 do | |
local operator = expr[i] | |
local num2 = eval(expr[i+1]) |
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
/* | |
* [The "BSD license"] | |
* Copyright (c) 2012 Terence Parr | |
* Copyright (c) 2012 Sam Harwell | |
* All rights reserved. | |
* | |
* Redistribution and use in source and binary forms, with or without | |
* modification, are permitted provided that the following conditions | |
* are met: | |
* |
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 Antlr.Runtime; | |
public class CaseInsensitiveStringStream : ANTLRStringStream | |
{ | |
// the string used for lookahead (performance improvement by not having to call Char.ToLowerInvariant()) | |
private readonly string _lastring; | |
public CaseInsensitiveStringStream(string input, string sourceName) | |
: base(input, sourceName) | |
{ |
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
-- debug helper function | |
function _dump (t) | |
local ttype = type(t) | |
if ttype == "table" then | |
local vals = {} | |
for k,v in pairs(t) do | |
table.insert(vals, _dump(k) .. " = " .. _dump(v)) | |
end | |
return "{"..table.concat(vals, " , ").."}" | |
elseif ttype == "string" then |
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.RegularExpressions; | |
namespace Mindplay.Extensions | |
{ | |
/// <summary> | |
/// This extension provides an alternative to <see cref="String.Format"/> allowing the | |
/// use of an <see cref="IDictionary{String,Object}"/> to replace named (rather than |