Skip to content

Instantly share code, notes, and snippets.

@martani
martani / qs_cent.sh
Created Feb 8, 2012
Quadratic Sieve running time
View qs_cent.sh
<<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)
@martani
martani / gist:1503951
Created Dec 21, 2011
Pollard's rho factoring method execution time
View gist:1503951
$ ./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 / pollard-rho.c
Created Dec 21, 2011
Pollard's rho factoring method
View pollard-rho.c
/*
* pollard-rho.c
* Created on: Dec 20, 2011
* Author: martani
*/
#include <stdlib.h>
#include <stdio.h>
#include <gmp.h>
View gist:1139493
let a = 14
List.fold_left a i
@martani
martani / gist:1107371
Created Jul 26, 2011
gettimeofday_benchmark
View gist:1107371
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);
@martani
martani / gist:1107347
Created Jul 26, 2011
nanosleep(), usleep() and sleep() benchmark
View gist:1107347
$ ./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:944969
Created Apr 27, 2011
Vegenere Decipher
View gist:944969
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:944949
Created Apr 27, 2011
Splitting Vigenere cipher into Caesar groups
View gist:944949
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]);
View keybase.md

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: