Skip to content

Instantly share code, notes, and snippets.

@dongho-jung
dongho-jung / obfucate2double.cpp
Created June 3, 2017 07:06
Obfuscate string 2 double :3
#include <iostream>
#include <random>
using namespace std;
void obfuscate2double(const char obfuscatedString[], int stringCount, double*& obfuscatedDouble, int& doubleCount) {
random_device rd;
mt19937 gen(rd());
uniform_int_distribution<> pickRandom(3, 7);
@dongho-jung
dongho-jung / stringSwitch.cpp
Last active June 10, 2017 04:55
It makes switch be able to treat string.
// Hash function by http://blog.naver.com/PostView.nhn?blogId=devmachine&logNo=220952781191
// Hash const by http://www.sysnet.pe.kr/Default.aspx?mode=2&sub=0&pageno=0&detail=1&wid=1223
#include <iostream>
using namespace std;
constexpr unsigned int HashCode(const char* str) {
return str[0] ? static_cast<unsigned int>(str[0]) + 0xEDB8832Full * HashCode(str + 1) : 8603;
}
@dongho-jung
dongho-jung / base64.py
Created June 14, 2017 07:38
Base64 encode / decode own implmentation
from struct import *
base64table = """
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
"""[2:-2]
def base64encode(string, charset='utf-8'):
binariedString = ''.join(map(lambda x: bin(x)[2:].rjust(8,'0'),bytearray(string, charset)))
@dongho-jung
dongho-jung / eratosthenesSieve.py
Created July 28, 2017 10:33
get prime number between given range.
start, end = [int(x) for x in input().split()]
sieve = list(range(0,end+1))
primeList = [2]
for i in primeList:
for j in range(i*2, end+1, i):
sieve[j] = 0
for j in range(i+1, end+1):
@dongho-jung
dongho-jung / Stack.py
Created July 31, 2017 13:46
Stack own implementation..
class Stack:
def __init__(self, maximum = 0):
self.__currentIdx = -1
self.__list = list()
self.__maximum = maximum
def push(self, newElement):
if(self.__currentIdx + 1 < self.__maximum or self.__maximum == 0):
self.__currentIdx += 1
@dongho-jung
dongho-jung / obfuscateByShape.js
Created July 31, 2017 13:58
obfuscate characters by its shape. and also supports l33t, 야민정음, else
<script>
var prob = 0.8;
String.prototype.replaceAt = function(index, character) {
return this.substr(0, index) + character + this.substr(index + 1);
}
function randomRange(n1, n2) {
return Math.floor((Math.random() * (n2 - n1 + 1)) + n1);
}
@dongho-jung
dongho-jung / recursiveObjectView.js
Created July 31, 2017 14:08
this script dismantle an object recursively
<script>
function clickme(){
var display = document.getElementById('display');
var sample = {a:1 , b:2 , c:3 , d:{q:1,w:2,e:3,f:{z:'hmm', x:'oh', c:'exe'}}};
var i;
var allElement = 'window\r\n';
allElement += inspect(window,1);
display.innerText = allElement;
@dongho-jung
dongho-jung / pos2key.py
Created September 19, 2017 08:10
위치 기반 함수 구문을 키값 기반으로 치환
import re
fileList = ['test.txt']
funcList = {
'foo': ['first','second'],
'bar': ['hana','dul','saet']
}
funcPatternList = ['({})\({}\)'.format(func, ('(.+?),'*len(funcList[func]))[:-1] ) for func in funcList]
@dongho-jung
dongho-jung / CodeRefactor.py
Created September 20, 2017 07:21
class for general code refactoring
import re
class CodeRefactor():
def __init__(self):
pass
def __pos2keyRepl(self, m, maxArgs=32):
args = funcList[m.group(1)]
sub = [ args[key]+'='+val for val, key in zip(m.groups()[1:], range(0,32)) ]
return m.group(1)+'('+','.join(sub)+')'
@dongho-jung
dongho-jung / Thanos.py
Created May 26, 2018 04:02
Thanos with quantum API
import urllib.request, json
class Thanos:
def __init__(self):
print('Bye, World!')
self.MAX_RANDOM = 1024
def finger_snap(self, world):