Skip to content

Instantly share code, notes, and snippets.

View byronhe's full-sized avatar

byronhe byronhe

View GitHub Profile
@byronhe
byronhe / ensure_single_process.cpp
Created April 5, 2016 15:31
ensure_single_process
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/un.h>
void ensure_single_process(const char * id){
struct sockaddr_un sun;
if(NULL==id || strlen(id)+1>sizeof(sun.sun_path)){
@byronhe
byronhe / https_client.php
Last active December 29, 2015 15:44
https client
<?php
$url="https://weixin.qq.com";
$url="https://www.alipay.com";
$url="https://www.baidu.com";
// Initialize session and set URL.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
// Set so curl_exec returns the result instead of outputting it.
#include <sodium.h>
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
/*
* reference:
* https://download.libsodium.org/doc/password_hashing/index.html
@byronhe
byronhe / ecdsa_demo.cpp
Created August 11, 2015 15:08
ecdsa key generate / sign / verify demo
#include <openssl/ecdsa.h>
#include <openssl/ecdh.h>
#include <openssl/evp.h>
#include <openssl/sha.h>
#include <openssl/bio.h>
#include <openssl/pem.h>
#include <iostream>
#include <string>
#include <cassert>
@byronhe
byronhe / modern_crypto.md
Last active March 28, 2022 07:51
现代密码学实践指南[2015年]

现代密码学实践指南[2015年]

标签(空格分隔): 密码学


本文介绍目前现代密码学的最先进技术, 前半部分主要翻译自 《Cryptographic Right Answers》,附上收集的资料,和byron个人的理解。

@byronhe
byronhe / rsa_oaep.go
Created May 22, 2015 08:14
rsa oaep 2048 sha256
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/sha256"
"log"
)
func main() {
@byronhe
byronhe / patch_elf.cpp
Created April 2, 2014 09:51
replace a C function at runtime , for unit test。
#include <stdint.h>
#include <iostream>
#include <string>
#include <unistd.h>
#include <string.h>
#include <sys/mman.h>
#include "patch_elf.h"
using namespace std;