Skip to content

Instantly share code, notes, and snippets.

View melvyniandrag's full-sized avatar
🌕
A Picture of Jupiter and 4 of its Moons Through Our Telescope.

melvyniandrag

🌕
A Picture of Jupiter and 4 of its Moons Through Our Telescope.
View GitHub Profile
@melvyniandrag
melvyniandrag / main.cxx
Last active January 15, 2018 17:25
lambda functions
#include "template.h"
#include <vector>
#include <iostream>
int main(){
std::vector<int> V{1, 2, 3, 4, 5};
std::vector<int> filtered = filter( [](int i){return i %2 == 0;}, V);
for( auto f : filtered ){
std::cout << f << std::endl;
}
class A( object ):
def __init__( self ):
print("A")
super( A, self ).__init__()
class B( object ):
def __init__( self ):
print("B")
super( B, self ).__init__()
@melvyniandrag
melvyniandrag / aes256.java
Last active November 7, 2017 17:55
aes 256 in grypt / java
import javax.crypto.spec.SecretKeySpec;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import java.util.Base64;
public class Test{
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws Exception{
@melvyniandrag
melvyniandrag / gcrypt_aes256.cpp
Created November 7, 2017 17:16
aes 256 in grypt
#include <cassert>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <gcrypt.h>
#include <string>
@melvyniandrag
melvyniandrag / pthread.cpp
Created November 1, 2017 17:39
start p thread with static wrapper around non static function
#include <unistd.h>
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <pthread.h>
class Base{
public:
int x;
@melvyniandrag
melvyniandrag / noWorks.cpp
Created November 1, 2017 17:08
function ptrs to member functions and pthreads with member functions.
#include <unistd.h>
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <pthread.h>
class Base{
public:
int x;
@melvyniandrag
melvyniandrag / ECDH_BC.java
Created August 31, 2017 20:28 — forked from wuyongzheng/ECDH_BC.java
Elliptic curve Diffie–Hellman using Bouncy Castle v1.50 example code
import java.math.BigInteger;
import java.security.PublicKey;
import java.security.PrivateKey;
import java.security.KeyFactory;
import java.security.Security;
import java.security.KeyPairGenerator;
import java.security.KeyPair;
import java.security.SecureRandom;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.ECGenParameterSpec;
@melvyniandrag
melvyniandrag / main.cpp
Last active August 31, 2017 17:06
Test the performance of unordered vs ordered containers.
/*
* Small test of the performance of
* - unordered_set vs set
* - unordered_map vs map
* Compile with g++ main.cpp -std=c++11
* As expected, the unordered versions are faster because they use hash functions, not trees.
*/
#include <unordered_map>
#include <map>
@melvyniandrag
melvyniandrag / main.cpp
Last active August 29, 2017 18:48
Creating and sharing ECDH keys to create a shared secret with openssl.
/*
Compile me with g++ main.cpp -lssl -lcrypto
The computeNeededSharedMemory() function has alot of stuff that is duplicated in main(). It should be refactored.
Also I forgot to free some stuff at the end. Just add the appropriate calls to the appropriate free methods. For me, its lunchtime
now.
*/
#include <cassert>
#include <string>
@melvyniandrag
melvyniandrag / main.cpp
Created August 25, 2017 19:33
Integrating OpenSSL and MPI for testing purposes.
#include <mpi.h>
#include <openssl/evp.h>
#include <openssl/ec.h>
#include <iostream>
#include <cstring>
#include <cassert>
void handleErrors(){
;
}