All I'm doing is "reinterpreting" a string (old school type) as a vector of unsigned longs ("tape"). First I loop the whole string 32 times. Then I "squash" it to 5/8 its length by getting rid the three highest bits of each byte. Finally I copy the chars to the vector by typecasting ... I think it's right. See any problems?
taperecorder::taperecorder(char* userphrase){ // derive
record_mode = false;
playhead = 0;
int len8 = 32*strlen(userphrase);
int len5 = 20*strlen(userphrase);
unsigned char* p8 = new unsigned char [len8 + 1]; p8[0] = '\0';
unsigned char* p5 = new unsigned char [len5 + 1];
for (int i=0; i<32; i++) strcat(p8, userphrase);
for (int i=0; i<len5; i++){//pack 5:8
p5[i] = 0;
for (int bit=0; bit<8; bit++){
int m = 8*i + bit;
if (p8[m/5]&(1<<(m%5))!=0) p5[i]|=(1<<bit);
}
}
tape.resize(len5/4);
for (int i=0; i<len5; i+=4){
tape[i/4] = unsigned int()p5[i];
}
delete [] newphrase;
}
