Skip to content

Instantly share code, notes, and snippets.

@kozmonaut
kozmonaut / rsa-keys.py
Created April 14, 2014 10:47
Extraction of RSA keys
#Extract RSA keys in separate files
"""
Example of usage:
1. Generate your RSA keys
# openssl genrsa 2048 > mykeys.key
2. Read keys in human way and save it to a new .txt file
# openssl rsa -in mykeys.key -noout -text
3. Exclude keys in separate files with rsa-keys.py script
"""
@kozmonaut
kozmonaut / makefile
Created April 8, 2014 13:40
Socket: Makefile example
all: client.o server.o
client.o: client-beta.c poruke.h
gcc client-beta.c -o client
server.o: server-beta.c
gcc server-beta.c -o server
clean:
rm server-beta.c server.exe client-beta.c client.exe poruke.h
@kozmonaut
kozmonaut / pyhash.py
Created April 8, 2014 09:27
Text hashing (sha1,md5,sha256)
#!/usr/bin/env python2.7
import hashlib
algorithms = dict(
md5 = lambda s: hashlib.md5(s).hexdigest(),
sha1 = lambda s: hashlib.sha1(s).hexdigest(),
sha256 = lambda s: hashlib.sha256(s).hexdigest(),
)
@kozmonaut
kozmonaut / mongoDB-logging.php
Last active June 16, 2018 16:27
Example of how to use mongoDB for storing apache access logs
<?php
// Initialize connection
try{
$mongo = New Mongo();
$db = $mongo->test;
$collection = $db->logs;
;
} catch (MongoConnectionException $check){
die ('Error msg: '. $check->getMessage());
@kozmonaut
kozmonaut / mongo-generate-data.php
Last active December 21, 2015 05:19
Some sample data for mongoDB.
<?php
// Define connection and name of database/collection for storing data
try{
$mongo = new Mongo();
$db = $mongo->myfirstdb;
$collection = $db->samples;
}catch(MongoConnectionException $check){
die('Database connection failed!'. $check->getMessage());