For Rasberry pi
Updated: spaniakos 2015
This Demonstrates the user friendly implementation. NOTE:
calc_size Function calculates the size for the ciphertext.
#include <DES.h>
#include "printf.h"
int calc_size(int size);
double ms;
int main(int argc, char** argv) {
printf("\n============================================\n");
printf(" Triple DES sample for Arduino/Raspberry pi\n");
printf("============================================\n");
des.
init(
"012345677654321001234567\0",(
unsigned long long int)0);
byte plaintext[] = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
byte ciphertext[calc_size(sizeof(plaintext))];
byte plaintext_p[sizeof(ciphertext)];
des.
do_3des_encrypt(plaintext,
sizeof(plaintext),ciphertext,
"012345677654321001234567\0");
printf(
" Encryption took %f ms\n",(des.
millis() - ms));
printf(
" Decryption took %f ms\n",(des.
millis() - ms));
return 0;
}
int calc_size(int size){
size = size + (8 - (size % 8)) - 1;
return size;
}