Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am martani on github.
  • I am martani (https://keybase.io/martani) on keybase.
  • I have a public key whose fingerprint is 44CE 0F6C 84E2 CA9C 0B0B 643E E05E 0DD5 E21E 38D5

To claim this, I am signing this object:

@martani
martani / gist:944949
Created April 27, 2011 19:07
Splitting Vigenere cipher into Caesar groups
static List<string> SplitTextWithKeyLen(string text, int keyLen)
{
List<string> result = new List<string>();
StringBuilder[] sb = new StringBuilder[keyLen];
for (int i = 0; i < keyLen; i++)
sb[i] = new StringBuilder();
for (int i = 0; i < text.Length; i++)
sb[i % keyLen].Append(text[i]);
@martani
martani / gist:944969
Created April 27, 2011 19:18
Vegenere Decipher
static string DecipherVeginere(string text, string key)
{
StringBuilder result = new StringBuilder();
int keyLength = key.Length;
int diff;
char decoded;
for (int i = 0; i < text.Length; i++)
{
diff = text[i] - key[i%keyLength];
@martani
martani / gist:1107347
Created July 26, 2011 17:49
nanosleep(), usleep() and sleep() benchmark
$ ./time
Call to nsleep(970000) took 970149
Call to usleep(970000) took 970143
Call to sleep(1) took 1000154
$ ./time
Call to nsleep(970000) took 970105
Call to usleep(970000) took 970169
Call to sleep(1) took 1000142
@martani
martani / gist:1107371
Created July 26, 2011 17:56
gettimeofday_benchmark
void gettimeofday_benchmark()
{
int i;
struct timespec tv_start, tv_end;
struct timeval tv_tmp;
int count = 1 * 1000 * 1000 * 50;
clockid_t clockid;
int rv = clock_getcpuclockid(0, &clockid);
let a = 14
List.fold_left a i
qdfsdf
@martani
martani / pollard-rho.c
Created December 21, 2011 00:22
Pollard's rho factoring method
/*
* pollard-rho.c
* Created on: Dec 20, 2011
* Author: martani
*/
#include <stdlib.h>
#include <stdio.h>
#include <gmp.h>
@martani
martani / gist:1503951
Created December 21, 2011 00:30
Pollard's rho factoring method execution time
$ ./pollard-rho 18446744073709551617
Factoring 18446744073709551617 ..
Testing GCD: 274177
Found divisor g = 274177 in 901 steps [0.004 s]
$ ./pollard-rho 10023859281455311421
Factoring 10023859281455311421 ..
Testing GCD: 1308520867
Found divisor g = 1308520867 in 25601 steps [0.037 s]
@martani
martani / qs_cent.sh
Created February 8, 2012 23:22
Quadratic Sieve running time
<<intel i7>>
N = 676292275716558246502605230897191366469551764092181362779759 (60 digits | 199 bits)
Time = ~17 hours
<<intel i3>>
N = 139920333957092418127239064840267210440539 (42 digits | 137 bits)
Time = 66 minutes
<<intel i7>>
N = 5705979550618670446308578858542675373983 (40 digits | 133 bits)