tea-encrypt.c ora cicla tutta la stringa

This commit is contained in:
Giulio De Pasquale 2017-05-25 16:59:28 +02:00
parent a6475f3500
commit 2bc3b17123

View File

@ -16,7 +16,7 @@ void encrypt(uint16_t *v) {
sum += delta;
v0 += ((v1 << 4) + k0) ^ (v1 + sum) ^ ((v1 >> 5) + k1);
v1 += ((v0 << 4) + k2) ^ (v0 + sum) ^ ((v0 >> 5) + k3);
printf("Intermediate v0: 0x%x | v1: 0x%x\n", v0, v1);
//printf("Intermediate v0: 0x%x | v1: 0x%x\n", v0, v1);
}
printf("SUM: 0x%x\n", sum);
printf("v0: 0x%x, v1: 0x%x\n", v0, v1);
@ -27,7 +27,6 @@ void encrypt(uint16_t *v) {
int main(int argc, char *argv[]) {
uint8_t *buf;
uint32_t buflen, i;
if (argc != 2) {
printf("Usage: %s text_to_encrypt", argv[0]);
exit(1);
@ -35,7 +34,9 @@ int main(int argc, char *argv[]) {
buflen = strlen(argv[1]);
buf = (uint8_t *)malloc(buflen);
memcpy(buf, argv[1], buflen);
encrypt((uint16_t *)buf);
for (i = 0; i < buflen; i+=2) {
encrypt((uint16_t *)&buf[i]);
}
printf("Result:\n");
for (i = 0; i < buflen; i++) {
printf("%02x", buf[i]);