Skip to content

Instantly share code, notes, and snippets.

View rawinng's full-sized avatar
🎯
Focusing

Rawin Ngamloet rawinng

🎯
Focusing
View GitHub Profile
const forge = require('node-forge');
const { pki, md, util } = forge;
const { rsa } = pki;
function encryptByForge(message, publicKey) {
// const buffer = util.createBuffer(message, "utf8"); // FIX THIS
const buffer = Buffer.from(message, "utf-8");
const encrypted = publicKey.encrypt(buffer, "RSA-OAEP", {
md: md.sha256.create(),
mgf1: {
@rawinng
rawinng / ed25519-poc.js
Last active February 10, 2022 15:25
POC for ED25519 on node (requires crypto and ed25519 lib)
var crypto = require('crypto');
var ed25519 = require('ed25519');
var random = crypto.randomBytes(32);
console.log(`seed: ${random.toString('hex')}`);
var keyPair = ed25519.MakeKeypair(random);
console.log(`privateKey: ${keyPair.privateKey.toString('hex')}`);
console.log(`publicKey: ${keyPair.publicKey.toString('hex')}`);
git log 28721b9..HEAD - no-merges - pretty="%h %s (%an %ae - %ad)"
@rawinng
rawinng / connect-ftx.js
Created December 16, 2021 09:23
Sample connection to FTX exchange.
var hmacSHA256 = require("crypto-js/hmac-sha256");
var hex = require("crypto-js/enc-hex");
var ftxConf = require("../conf/ftx");
var axios = require("axios");
const signRequest = (method, url, body = null) => {
const ts = new Date().getTime();
var payload = `${ts}${method}${url}`;
if (body !== null) {
payload += `${body}`;
@rawinng
rawinng / connect-bitkub.js
Created December 16, 2021 09:22
Connect to Bitkub API
var hmacSHA256 = require("crypto-js/hmac-sha256");
var hex = require("crypto-js/enc-hex");
var axios = require("axios");
var bitkubConf = require("../conf/bitkub");
const requestBitkub = async (method, url, body = null) => {
const headers = {
Accept: "application/json",
"Content-Type": "application/json",
"X-BTK-APIKEY": bitkubConf.apiKey,

Keybase proof

I hereby claim:

  • I am rawinng on github.
  • I am rawinng (https://keybase.io/rawinng) on keybase.
  • I have a public key ASBmVDYkYsJAeOF5Z2TVoUR06HBTmYdevxtijprQ4-NV3go

To claim this, I am signing this object:

def main():
n = int(input("Input any number : "))
print_diamond(n)
def print_diamond(n):
s = str(int('1'*n)**2)
print(s)
f = '%'+str(n-1)+'s'
for i in map(int,s):
print(f % s[:i-1]+s[-i:])
## Diamon
def main():
n = int(input(f"Input any number : "))
a = build_diamond(n)
result = []
for i in a:
result.append([ str(n) if n > 0 else " " for n in i ])
for i in result:
mvn -N io.takari:maven:0.7.7:wrapper
" change leader key
let mapleader = "\<Space>"
" vim plug start
call plug#begin('~/.vim/plugged')
Plug 'sheerun/vimrc'
Plug 'sheerun/vim-polyglot'
Plug 'junegunn/vim-easy-align'
Plug 'scrooloose/nerdtree',{'on':'NERDTreeToggle'}