Skip to content

Instantly share code, notes, and snippets.

@stravant
Created September 18, 2012 16:24
Show Gist options
  • Save stravant/3744089 to your computer and use it in GitHub Desktop.
Save stravant/3744089 to your computer and use it in GitHub Desktop.
Ardiuno Encrypt
delay(100);
randomSeed(micros());
int generator = 0;
int primmod = 0;
int priv_key = random(1000,10000);
void setup() {
Serial.open(9600);
Serial1.open(9600);
//
if (Serial1.available()) {
while (true) {
while (!Serial1.available());
int dat = Serial1.read();
if (dat == 'r') {
Serial1.write('w');
while (true) {
int a = Serial1.read();
if (a != 'w') {
generator = a-128;
primmod = Serial1.read()-128;
goto done;
}
}
}
}
done:
//
} else {
while (!Serial1.available()) {
Serial1.write('r');
}
if (Serial1.read() == 'w');
generator = 5;
primmod = 37;
Serial1.write(generator+128);
Serial1.write(primmod+128);
}
//
Serial.print("Got Keys: gen=");
Serial.print(generator);
Serial.print(", mod=");
Serial.println(primmod);
//
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment