Skip to content

Instantly share code, notes, and snippets.

View xenomancer's full-sized avatar
🔥
work work work

Craig Mansfield xenomancer

🔥
work work work
View GitHub Profile
@xenomancer
xenomancer / sha2.h
Created July 7, 2022 14:40
A simple implementation of the SHA2 series of hash functions with vector and string return values. Returning to an array pointer provided as a function argument is out of the scope of this implementation, but may be implemented following the first vector return type functions defined for each class. The global scope functions serve as syntactic …
#pragma once
#include <stdlib>
#include <vector>
#include <string>
#define SHA2_SHFR(x, n) (x >> n)
#define SHA2_ROTR(x, n) ((x >> n) | (x << ((sizeof(x) << 3) - n)))
#define SHA2_ROTL(x, n) ((x << n) | (x >> ((sizeof(x) << 3) - n)))
#define SHA2_CH(x, y, z) ((x & y) ^ (~x & z))
#define SHA2_MAJ(x, y, z) ((x & y) ^ (x & z) ^ (y & z))
@xenomancer
xenomancer / TEA.cpp
Last active May 6, 2022 18:46
TEA, the Tiny Encryption Algorithm
#include <stdint.h>
// key schedule constant
#define delta 0x9e3779b9
void encrypt (uint32_t* v, uint32_t* k) {
// setup
uint32_t v0 = v[0];
uint32_t v1 = v[1];
uint32_t sum = 0;
@xenomancer
xenomancer / more_trig_and_hyp_v0000.h
Created May 3, 2022 16:57
Header only definition of additional trigonometric, hyperbolic, and respective inverse functions for the secant (sec), cosecant (csc), cotangent (cot), chord (crd), versed sine (versin), coversed sine (coversin), versed cosine (vercos), coversed cosine (covercos), half versed sine (haversin), half coversed sine (hacoversin), half versed cosine (…
// Copyright © Craig D. Mansfield, 2022, no rights reserved.
// This software is free and open source with no limitations, restrictions, or liability.
// Use it at your own risk.
// If you like this software then you can buy me a beer if we meet in the future.
#pragma once
#include <cmath>
#include <complex>
using namespace std;
@xenomancer
xenomancer / XTEA.cpp
Created March 29, 2022 14:48
XTEA, the eXtended Tiny Encryption Algorithm
#include <stdint.h>
// key schedule constant
#define delta 0x9e3779b9
void encrypt (uint32_t n, uint32_t* v, uint32_t* k) {
// setup
uint32_t v0 = v[0];
uint32_t v1 = v[1];
uint32_t sum = 0;
### Keybase proof
I hereby claim:
* I am xenomancer on github.
* I am craigbob99 (https://keybase.io/craigbob99) on keybase.
* I have a public key ASAEVgt8Un2dV2HysY8ffHSQUCDBTeQuuDdLvItS_crTggo
To claim this, I am signing this object:
@xenomancer
xenomancer / raw_crypt_alt.h
Last active April 11, 2021 15:55
A standalone alternative to a quick encryption/decryption part of a project. Based on simple Feistel network with some modification to perform as a pseudo-unbalanced network with more than two blocks allowed.
// Copyright Craig D. Mansfield 2021, zero rights reserved.
// TO the extent that it is possible under law, this is released to the public domain.
// Do with this as you please. Consider this beerware.
// If you like what I wrote and we ever meet up, you can buy me a beer.
// This is a header only c++ implementation.
// Assuming compiler uses c++14 spec or later.
#pragma once
#include <stdlib>
@xenomancer
xenomancer / keybase.md
Created April 17, 2017 02:20
keybase.io confirmation

Keybase proof

I hereby claim:

  • I am xenomancer on github.
  • I am xenomancer (https://keybase.io/xenomancer) on keybase.
  • I have a public key whose fingerprint is 8198 CB90 329E D119 FF3A C748 E837 208F E817 DA7D

To claim this, I am signing this object: