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
def extended_euclid_gcd(a: int, b: int) -> list: | |
""" | |
Returns [gcd(a, b), x, y] where ax + by = gcd(a, b) | |
""" | |
s, old_s = 0, 1 | |
t, old_t = 1, 0 | |
r, old_r = b, a | |
while r != 0: | |
quotient = old_r // r | |
old_r, r = r, old_r - quotient * 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
import hashlib | |
from binascii import hexlify | |
def sha256(payload: bytes) -> bytes: | |
return hashlib.sha256(payload).digest() | |
def double_sha256(payload: bytes) -> bytes: | |
return sha256(sha256(payload)) |
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
from ec_point_operation import curve | |
from crypto import ripemd160_sha256, b58check_encode, b58check_decode | |
from binascii import hexlify | |
def int_to_varint(value: int) -> bytes: | |
if value <= 0xfc: | |
return value.to_bytes(1, 'little') | |
elif value <= 0xffff: | |
return b'\xfd' + value.to_bytes(2, 'little') |
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
from pytz import timezone | |
from datetime import datetime | |
now = timezone('Asia/Shanghai').fromutc(datetime.utcnow()) | |
print(now.strftime('%Y-%m-%d %H:%M:%S')) |
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
from bitsv.base58 import b58encode, b58decode | |
from bitsv.crypto import ECPrivateKey, sha256, hash160 | |
from binascii import hexlify | |
# | |
# pip install bitsv | |
# | |
# https://aaron67.cc/2019/01/04/bitcoin-address/ | |
# | |
print() |
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
// https://github.com/crypto-browserify/pbkdf2 | |
// | |
const crypto = require('crypto'); | |
const hash = 'sha512' | |
const round = 2048 | |
const seed_bytes = 64 | |
var mnemonic = 'furnace tunnel buyer merry feature stamp brown client fine stomach company blossom' | |
var passphrase = '' |
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
// | |
// main.cpp | |
// hex-to-oct | |
// | |
// Created by aaron67 on 2017/1/23. | |
// Copyright © 2017年 aaron67. All rights reserved. | |
// | |
#include <iostream> | |
#include <iomanip> |
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
// | |
// main.cpp | |
// hex-to-oct | |
// | |
// Created by aaron67 on 2017/1/23. | |
// Copyright © 2017年 aaron67. All rights reserved. | |
// | |
#include <iostream> | |
#include <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
Show hidden characters
{ | |
"auto_complete": true, | |
"auto_complete_commit_on_tab": true, | |
// 在选中区域搜索 | |
"auto_find_in_selection": true, | |
"bold_folder_labels": true, | |
"color_scheme": "Packages/Color Scheme - Default/Monokai Bright.tmTheme", | |
"create_window_at_startup": false, | |
"draw_white_space": "all", | |
"highlight_line": 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
// | |
// main.cpp | |
// two-eggs-problem | |
// | |
// Created by aaron67 on 15/2/12. | |
// Copyright (c) 2015年 aaron67. All rights reserved. | |
// | |
// 参考:http://ppwwyyxx.com/2013/Problem-of-Two-Eggs/ | |
// | |
// 题目描述: |