Skip to content

Instantly share code, notes, and snippets.

View b1ek's full-sized avatar
👋
Coding

blek! b1ek

👋
Coding
View GitHub Profile
@b1ek
b1ek / array_to_table.php
Created October 24, 2022 08:21
PHP array to table
<?php
function arr2table($array, $headers = true) {
$buffer = '<table><tbody><tr>' . ($headers ? '<td>Index</td>' : '');
foreach($array as $i => $val) {
$buffer .= "<td>$i</td>";
}
$buffer .= '</tr>' . ($headers ? '<td>Value</td>' : '');
foreach($array as $i => $val) {
$buffer .= '<td>' . print_r($val, true) . '</td>';
}
@b1ek
b1ek / enc.py
Last active December 1, 2022 11:10
Python C string encryption
import random as r, time as t
STRING = 'You are gay\n';
offset = r.randint(0, 10000);
encryptS = list();
c = 0;
def rands(sz): return ''.join(r.choices(list('abcdef1234567890'), k=sz));
for i in STRING:
@b1ek
b1ek / README.md
Created September 17, 2022 15:09
Python ssl

Please DON'T use this.

This is just a toy project i wrote for fun.
You can use this for studiyng RSA, but if you want proper RSA encryption in your project, use a cryptography library.

from math import gcd

def prime(x):
    count = 0
    for i in range(int(x/2)):
        if x % (i+1) == 0:
@b1ek
b1ek / README.md
Created September 17, 2022 13:13
Carmichael function python
from math import gcd
def carmi(n):
    copr = [x for x in range(1, n) if gcd(x, n) == 1]
    k = 1
    while not all(pow(x, k, n) == 1 for x in copr):
        k += 1
    return k

If you get an import error on line 1, change math to fractions and see how it works

@b1ek
b1ek / string_enc.md
Last active September 5, 2022 00:29
C string encryption

To edit the string, change it in the variable in the file at line 3.

import random as r, time as t

STRING = 'ur gay';
offset = r.randint(0, 10000);
encryptS = list();
c = 0;
@b1ek
b1ek / Email Regex.md
Last active August 17, 2022 09:53
Email Regex
^[a-zA-Z0-9._]+@\w+(\.\w{2,}){1,}$
@b1ek
b1ek / brainf.md
Last active August 7, 2023 22:24
Brainfuck compiler

Brainfuck compiler

Pretty much the title. Array length is not limited to 30000 anymore, it is calculated on the compile time.
It passed all the tests

Input file: file.txt
Out file: out.c

It is compiled to c code

program.c

@b1ek
b1ek / reverse_array.py
Created January 15, 2022 16:16
reverse python array
def reverse_array(array: list) -> list:
out = [];
i = len(array) - 1;
while (1):
out.append(array[i]);
if (i == 0): return out;
i -= 1;