View previous topic :: View next topic |
Author |
Message |
Uzeil Moderator Reputation: 6
Joined: 21 Oct 2006 Posts: 2411
|
Posted: Sun Jun 13, 2010 7:51 am Post subject: First solver gets my third +rep ever |
|
|
So this is the joke.
My encryptor is as follows:
For each character in the string, starting with the first going to the last:
We shift each bit left once.
Then add 33
Then, if the character AND'd by 223 doesn't return 0, we shift each bit right once and subtract 16
Otherwise, we subtract 64 and THEN shift it right once.
We then XOR the resulting character by 179
Then we AND it by 127
Then we XOR is by 179 one more time.
Why does this encryption end up being easily converted to plain, readable text?
First to answer AND explain why their answer is correct(COMPLETELY EXPLAIN) get my first rep in 3 years, and third rep I've ever given ever ever Shit's valuable.
Everyone else has a moral obligation to bump.
P.S. If someone helps you get to the answer+explanation and you get my rep, you should damn well rep them too >_>
_________________
|
|
Back to top |
|
|
S3NSA :3 Reputation: 1
Joined: 06 Dec 2006 Posts: 1908 Location: England.
|
|
Back to top |
|
|
Slugsnack Grandmaster Cheater Supreme Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Sun Jun 13, 2010 8:21 am Post subject: |
|
|
Working on it..
Code: | #include <Windows.h>
#include <stdio.h>
void FormatString( char* szInput, char* szOutput, int nSize ) {
RtlZeroMemory( szOutput, 3 * nSize + 1 );
for( int i = 0; i < nSize; i++ ) {
sprintf_s( &szOutput[i*3], 3, "%02X", szInput[i] );
szOutput[ ( i + 1 )*3 - 1 ] = ' ';
}
}
int main() {
char szTestString[] = "my test string";
int cbLength = strlen( szTestString );
char* szFormattedPlain = ( char* )malloc( 3*cbLength + 1 );
FormatString( szTestString, szFormattedPlain, cbLength );
printf_s( "%s\n", szFormattedPlain );
free( szFormattedPlain );
for( int i = 0; i < cbLength; i++ ) {
szTestString[i] <<= 1;
szTestString[i] += 33;
if( ( szTestString[i] & 233 ) != 0 )
szTestString[i] = ( szTestString[i] >> 1 ) - 16;
else
szTestString[i] = ( szTestString[i] - 64 ) >> 1;
szTestString[i] ^= 179;
szTestString[i] &= 127;
szTestString[i] ^= 179;
}
printf_s( "%s\n", szTestString );
char* szFormattedEnc = ( char* )malloc( 3*cbLength + 1 );
FormatString( szTestString, szFormattedEnc, cbLength );
printf_s( "%s\n", szFormattedEnc );
free( szFormattedEnc );
getchar();
return 0;
} |
My FormatString function is fucked and crashing after on the input after encryption. Am guessing it's to do with signed/unsigned maybe.. Just bashed this shit together in minutes. I intend to see first how it is easily converted. Then why that happens. Out of interest who did your previous 3 reps go to ?
Need to go do something else now.. will work on this tonight.
|
|
Back to top |
|
|
Uzeil Moderator Reputation: 6
Joined: 21 Oct 2006 Posts: 2411
|
Posted: Sun Jun 13, 2010 5:25 pm Post subject: |
|
|
Previous 2 reps** and I don't remember =/ It was 3 years ago lol.
Where are my solvers D:<
_________________
|
|
Back to top |
|
|
Flyte Peanuts!!!! Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Sun Jun 13, 2010 6:03 pm Post subject: |
|
|
Explanation in comments. End result is that the ASCII character is preserved, except the high bit is set.
Code: | string Encrypt(string s) {
for(unsigned int i = 0; i < s.length(); i++) {
// Character becomes even -> 0nnn nnnn -> nnnn nnn0
s[i] <<= 1;
// Character becomes odd.
s[i] += 33;
// Check if it is odd, always is.
if(s[i] & 233) {
// Undoes the last two operations.
s[i] = (s[i] >> 1) - 16;
} /*else { // Junk
s[i] = (s[i] - 64) >> 1;
}*/
// Sets the high bit.
s[i] ^= 179;
// Clears the high bit.
s[i] &= 127;
// Reverses last xor. Except for the last bit.
s[i] ^= 179;
// End result. The high bit for every ascii character is set.
}
return s;
}
// What actually happens.
string SimpleEncrypt(string s) {
for(unsigned int i = 0; i < s.length(); i++) {
s[i] |= 0x80;
}
return s;
} |
|
|
Back to top |
|
|
Slugsnack Grandmaster Cheater Supreme Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Sun Jun 13, 2010 6:06 pm Post subject: |
|
|
well done
|
|
Back to top |
|
|
Uzeil Moderator Reputation: 6
Joined: 21 Oct 2006 Posts: 2411
|
Posted: Sun Jun 13, 2010 6:11 pm Post subject: |
|
|
Unfortunately I meant to XOR by 79, not 179, so it would end up the same as it first was . My excuse? Did this at 6:51am D:
Either way, I lubses you. +rep well earned (Why do I have more rep than you? You've been helping people lately more often than I have)
_________________
|
|
Back to top |
|
|
Slugsnack Grandmaster Cheater Supreme Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Sun Jun 13, 2010 6:12 pm Post subject: |
|
|
mainly because ipromise is fickle when it comes to allegiances
|
|
Back to top |
|
|
|