Skip to content

Instantly share code, notes, and snippets.

View dantsec's full-sized avatar
🐧
Talk is cheap, show me the code!

Cauê Santana dantsec

🐧
Talk is cheap, show me the code!
View GitHub Profile
@dantsec
dantsec / caesar.c
Created October 4, 2025 15:11
Caesar Crypt / Decrypt program.
// https://tryhackme.com/room/cryptographybasics
#include <stdio.h>
#include <ctype.h>
void encrypt(char msg[]) {
int rot = 0;
printf("Rot: ");
scanf("%d", &rot);
@dantsec
dantsec / automaton.cpp
Created July 1, 2025 02:47
A simple implementation of a 1D cellular automaton!
/**
* @file automaton.cpp
* @author dantsec (dantsec@proton.me)
* @brief A simple implementation of a 1D cellular automaton, based on ECA (Elementary Cellular Automata).
* @version 0.1
* @date 2025-06-30
*
* @copyright dantsec (c) 2025
*
* % g++ -std=c++11 -O2 -Wall automaton.cpp -o automaton && ./automaton 50 10 30 < in.txt
@dantsec
dantsec / ArrayOperationsTrait.php
Created May 21, 2025 19:25
Some complex array operations!
<?php
namespace App\Http\Traits;
trait ArrayOperationsTrait
{
/**
* Recursively computes the difference between two arrays.
*
* This method compares the first array ($arr1) with the second array ($arr2) and returns
@dantsec
dantsec / pseudorandom.py
Created March 18, 2025 02:35
Algorithm that generate pseudorandom numbers using unix epoque as seed!
import time
"""
Given the relation:
X0 = "Seed" (Important to have a source that garantee it'll be most random possible)
Xn = (A * Xn-1 + B) mod Y
Were:
A and B might have random source as seed (like atmospheric noises or system date)
Y are our delimiter, and generates X in range [0, Y - 1]
@dantsec
dantsec / app.js
Last active February 20, 2025 22:36
Simple node implementation of JWT with access and refresh token!
// Imports
const express = require('express');
const app = express();
const tokenUtil = require('./src/utils/Token');
const crypto = require('crypto');
// Constants
const accessSecret = 'ACCESS_SECRET_KEY';
const refreshSecret = 'REFRESH_SECRET_KEY';
const validLogin = {
@dantsec
dantsec / .vimrc
Created January 21, 2025 14:29
Simple and useful vim config!
" Disable compatibility with vi which can cause unexpected issues.
set nocompatible
" Enable type file detection. Vim will be able to try to detect the type of file in use.
filetype on
" Enable plugins and load plugin for the detected file type.
filetype plugin on
" Load an indent file for the detected file type.
@dantsec
dantsec / ConvertImagesToWebp.php
Created September 15, 2024 19:55
Convert images from your laravel public folder to webp!
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class ConvertImagesToWebp extends Command
{
/**
@dantsec
dantsec / recursive_array_merge.php
Created September 15, 2024 19:53
Merge two arrays (recursively) without overwriting keys!
<?php
/**
* Does indeed merge arrays, but it converts values with duplicate keys to arrays
* rather than overwriting the value in the first array with the duplicate
* value in the second array, as array_merge does.
*
* @param array $leftArray
* @param array $rightArray
*
@dantsec
dantsec / friendly_url.md
Created July 28, 2024 13:35
Friendly URLs @ Apache Config

Friendly URLs @ Apache Config

Documentation

  • Apache: https://httpd.apache.org/docs/current/mod/mod_rewrite.html

Instructions

Some Configs

@dantsec
dantsec / morse_encode.c
Created April 27, 2024 21:43
This algorithm encodes text to morse code.
/*
gcc morse_encode.c -o morse && ./morse
*/
#include <stdio.h>
#define ALPHABET_TOTAL_LETTERS (26)
#define ALPHABET_LINE_SIZE (10)
const char ALPHABET[ALPHABET_TOTAL_LETTERS][ALPHABET_LINE_SIZE] = {