In response to an inquiry on the full-disclosure mailing list, wherein somebody asked for a quick-and-dirty way of encrypting things from the command line, I have written xork. It is puny and weak, but it amused me.
I welcome any suggestions, as I am not l33t.
Update: Yes, I’m well aware that this is the cryptographic equivalent of the locks that tourists put on their luggage. Thank you.
5 Comments
%
% a matlab port of xork code
%
% input file names
f1=input(‘Filename to encrypt/decrypt: ‘,’s');
f2=input(‘Filename to use as cypher: ‘,’s');
f3=input(‘Output file name: ‘,’s');
% read in files
fid1=fopen(f1);
d1=fread(fid1,’*char’);
fclose(fid1);
fid2=fopen(f2);
d2=fread(fid2,’*char’);
fclose(fid2);
%xor files with wrap around
c=[];
for j = 1: length(d1)
c(end+1)=double(bitxor(uint8(d1(j)),uint8(d2(mod(j-1,length(d2))+1))));
end
%write output file
fid3=fopen(f3,’wb’);
d3=fwrite(fid3,char(c),’uchar’);
fclose(fid3);
Weeeeeeee :)
The following was also written in Matlab:
Warning: fsockopen(): unable to connect to 69.70.209.171:8000 in /var/www/quantumcat.off.net/html/index.php on line 78
!!! ERROR !!! — Sorry, can’t talk to the quantumcat server I wrote… I’m sorry some stuff won’t work.. so check back later… when this message is gone.. it’s working again! – sean.
Matlab: RAD tools for the flagrant overuse of exclamation points and ellipses.
Shouldn’t the fgetc in following snippet from xork.c be “xagchar=fgetc(….)”
> if (xagchar == EOF) {
> rewind(xor_against_file);
> fgetc(xor_against_file);
> }
Yes. Yes it should.
Fixed. Added key-weakness metric too, just for kicks.