Can someone please check my code (Yenc encrytion) Here the formula i used

The encoding process represents each octet of input data with a single corresponding encoded output character. The ASCII value of each output character is derived by the following simple formula:

O = (I+42) % 256

That is, the output value is equal to the ASCII value of each input character plus 42, all modulo 256. This reduces overhead by reducing the number of NULL characters (ASCII 00) that would otherwise have had needed to be escaped, since many binaries contain a disproportionately large number of NULLs).

And the code:

xor eax,eax

mov al, ;src ascii

add al,42

shr eax, 8 ;division of 256

mov ,al

Is this correct? its the phrases 'octet ' + 'modulo ' that have me asking....

thx. :)

The encoding process represents each octet of input data with a single corresponding encoded output character. The ASCII value of each output character is derived by the following simple formula:

O = (I+42) % 256

That is, the output value is equal to the ASCII value of each input character plus 42, all modulo 256. This reduces overhead by reducing the number of NULL characters (ASCII 00) that would otherwise have had needed to be escaped, since many binaries contain a disproportionately large number of NULLs).

And the code:

xor eax,eax

mov al, ;src ascii

add al,42

shr eax, 8 ;division of 256

mov ,al

Is this correct? its the phrases 'octet ' + 'modulo ' that have me asking....

thx. :)

modulo means taking the remainder left after division not a quotient.

`movzx eax, byte ptr `

add eax, 42

xor edx, edx

mov ecx, 256

div ecx

;now edx contains the needed remainder.

256 = 100h, so no div needed:

Ossa

`movzx eax, byte ptr `

add eax, 42

mov ,al

Ossa

It is pointless to bother with the modulus if you are dealing with byte operations as every addition has already a modulo 256 in it.

so just discard ah? :)

ie.

and eax, 0ffh

ie.

and eax, 0ffh

Your original equation is O = (I+42) % 256

If you want O to be in al and I is initally in al,

add al, 42

will give you (I+42) % 256

If you want O to be in al and I is initally in al,

add al, 42

will give you (I+42) % 256

Btw this is "encoding", not "encryption" :)