Skip to content

Instantly share code, notes, and snippets.

View iaoedsz2008's full-sized avatar
🏠
nothing

妙神 iaoedsz2008

🏠
nothing
  • China
View GitHub Profile
@iaoedsz2008
iaoedsz2008 / main.cpp
Last active May 20, 2019 02:30
c++跨平台高精度定时器
#include <iostream>
#include <chrono>
int main()
{
auto start = std::chrono::high_resolution_clock::now ();
/*
do something...
*/
auto end = std::chrono::high_resolution_clock::now ();
void hmac_sha512 (const unsigned char* input, int inputlength, unsigned char* output, unsigned int* outputlength)
{
const EVP_MD* engine = EVP_sha512 ();
#if OPENSSL_VERSION_NUMBER < 0x10100000L
HMAC_CTX ctx;
HMAC_CTX_init (&ctx);
HMAC_Init_ex (&ctx, API_SECRET, strlen (API_SECRET), engine, NULL);
HMAC_Update (&ctx, (const unsigned char*)input, inputlength);
HMAC_Final (&ctx, output, outputlength);
void hmac_sha256 (const unsigned char* input, int inputlength, unsigned char* output, unsigned int* outputlength)
{
const EVP_MD* engine = EVP_sha256 ();
#if OPENSSL_VERSION_NUMBER < 0x10100000L
HMAC_CTX ctx;
HMAC_CTX_init (&ctx);
HMAC_Init_ex (&ctx, API_SECRET_KEY, strlen (API_SECRET_KEY), engine, NULL);
HMAC_Update (&ctx, (const unsigned char*)input, inputlength);
HMAC_Final (&ctx, output, outputlength);
#include <openssl/bio.h>
#include <openssl/evp.h>
#include <openssl/buffer.h>
std::string base64_encode (const void* data, int len)
{
std::string ret;
BIO * bio, *b64;
BUF_MEM* bufferPtr;
@echo off
rem 使用前可以在注册表中添加项,以将此功能添加到文件夹的右键菜单
rem HKEY_CLASSES_ROOT\Directory\Background\shell\liaowuping\command
rem 并将默认值设置为此文件绝对路径
set Path=
rem cmake
set Path=%Path%;C:\Program Files\CMake\bin
@iaoedsz2008
iaoedsz2008 / iconv_utf8_to_localcharset.c
Last active September 6, 2019 09:32
convert utf8 to localcharset
#include <iconv.h>
#include <localcharset.h>
static iconv_t g_utf8_to_localcharset;
static int init_iconv ()
{
g_utf8_to_localcharset = NULL;
#if _WIN32
const char* charset = locale_charset ();
pragma solidity ^0.5.0;
interface IERC20 {
function name () external view returns (string memory);
function symbol () external view returns (string memory);
function decimals () external view returns (uint8 );
#include <openssl/md5.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
MD5_CTX c;
unsigned char data[] = "your data";
int len = strlen(data);
unsigned char md5[MD5_DIGEST_LENGTH] = {0};
@iaoedsz2008
iaoedsz2008 / clean_icon_cache.bat
Created October 8, 2019 10:32
Windows 强制刷新图标缓存
echo 正在关闭资源管理器...
taskkill /f /im explorer.exe
echo 正在清理系统图标缓存数据库...
attrib -h -s -r "%userprofile%\AppData\Local\IconCache.db"
echo /f "%userprofile%\AppData\Local\IconCache.db"
@iaoedsz2008
iaoedsz2008 / main.cpp
Last active March 30, 2020 16:38
std::unordered_map 自定义key类型
// hash 函数
struct sockaddr_in_hash
{
size_t operator()(const sockaddr_in &addr) const
{
return *(size_t*)&(addr.sin_addr);
}
};
// 每次查找时最少调用一次,hash值相同时可能调用2次或更多次.