|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Jun 2003
Città: Genova
Messaggi: 5676
|
xor
tentativo mal riuscito di cifrare un file con xor (solo per vedere se lo riesco a decifrare
Codice:
#include <iostream>
#include <fstream>
using namespace std;
int main(){
char primo;
char secondo;
char terzo;
ifstream in("a",ios_base::binary);
ifstream in1("b",ios_base::binary);
ofstream out("c",ios_base::binary);
while(!in.eof()){
in >> primo;
in1 >> secondo;
terzo = primo ^ secondo;
out << terzo;
}
in.close();
out.close();
in1.close();
return 0;
}
anche con una chiave abbastanza lunga fa degli errori. se ripasso lo xor con c e b non mi ridà a dove sbaglio? cia! |
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Aug 2001
Città: San Francisco, CA, USA
Messaggi: 13827
|
Il C++ non lo conosco, però in C ho fatto sta roba :
Codice:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
FILE *input, *output;
char *key;
long ent;
if (argc == 4 ) {
key = argv[1];
if ( (input = fopen(argv[2], "rb")) != NULL ) {
if ( (output = fopen(argv[3], "wb")) != NULL ) {
while ( (ent = fgetc(input)) != EOF) {
if ( *key == 0 )
key = argv[1];
ent ^= *key;
fputc(ent, output);
key++;
}
}
else {
printf("Il file di output non può essere aperto\n");
}
}
else
printf("Il file di input non può essere aperto\n");
}
else
printf("[usage]: xorcypher key input_file output_file\nMaggioni Marcello (2004) [email protected]\n");
fclose(input);
fclose(output);
return 0;
}
__________________
GPU Compiler Engineer |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 05:29.



















