News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

How to special encrypt file?

Started by royale, January 25, 2009, 06:15:16 AM

Previous topic - Next topic

royale

Like change a to 1, b to 2, c to 3. please helppp :dazzled:

Vortex

Try XORing all the bytes. It's a simple method but better then assigning sequential numbers to characters.

donkey

For a simple substitution cipher you can use XLATB and a table of values (0-255). The following example shows a way of translating to lower case using a substitution table, it will take a BYTE index value and replace it with the value from the table found at that index. For example the upper case letter A is 041h (65 decimal), it will be replaced by the BYTE at the 66th position in the table counting 0 (97 decimal (lower case a)). You can use any ordering for the table to make the results a little less sequential. You should note that this type of encryption breaks down very quickly with a simple statistical analysis of the frequency and position of letters.

lcase:
db   0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15
db  16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
db  32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47
db  48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63
db  64, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111
db 112,113,114,115,116,117,118,119,120,121,122, 91, 92, 93, 94, 95
db  96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111
db 112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127
db 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143
db 144,145,146,147,148,149,150,151,152,153,154,155,156,156,158,159
db 160,161,162,163,164,165,166,167,168,169,170,171,172,173,173,175
db 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191
db 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207
db 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223
db 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239
db 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255

.CODE
mov ebx,offset lcase
mov edi,[pString]
mov esi,[pString]
xor ecx,ecx
:
mov al,[esi+ecx]
xlatb
mov [edi+ecx],al
inc ecx
or al,al
jnz <
:


Note that this example terminates when the letter is NULL, that is the end of a C string, you would need a different way to determine the end for a file. Perhaps cbRead from the ReadFile function.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

royale


royale

ok it is not a to 1 , b to 2 and c to 3. I just found out the list was completely random. like a to a to 3, b to Z, c to 9.....