Hey guys, i've been looking everywhere for a simple encryption/decryption method, but can't find it anywhere!!
Basically, it gets a string, makes it into ASCII, adds an integer to the value, If above 255 take away 255, then converts it back into a string
for e.g.

abcdef --> bcdefg
zyxwvu --> yxwvut

It's so simple but i cna't figure it out.
Sorry about the noobishness of the topic :D:D:D:D
Posted on 2006-03-21 12:08:23 by looter

it gets a string, makes it into ASCII, adds an integer to the value, If above 255 take away 255, then converts it back into a string

This sounds like a homework assignment, since you've got the steps you want to take outlined the way you do..
ASCII chararacters are represented by BYTE values, and Strings are nothing more than a collection of
these values representing the characters.

String1  DB "abcd",0
is equal to:
String1  DB 97,98,99,100,0

SInce you're working with byte sized data in the strings, the integer you want to add to the string data should be byte sized also.
The rest should be fairly simple and straightforward to code.
Post some of your code when you get stuck, and we'll be glad to help, but don't expect someone to write it for you.

Posted on 2006-03-21 12:52:14 by rags
Thanks for the reply!
Well will it interpret abcd as 97, 98, 99, 100?
so if i add 1 to abcd without actually saying 97, 98, 99, 100, will it work?
Posted on 2006-03-21 13:12:51 by looter

When working with computers, there are really no such thing as the alphabet. It's all numbers. When you come across 'ABCD' in  your program's source, upon compilation, it is turned into 0x41, 0x42, 0x43, 0x44 so as far as your computer is concerned it's just numbers. You can do add eax, 'A' to add 0x41 to the value in eax just as easily as you could add eax, 0x41 because that's whats generated anyways. So for your 'assignment' just obtain the pointer to your string array (use the lea instruction if needbe), loop through the bytes, preform your algorithm, then when you hit a byte who's value is 0x00 stop encoding and fall through. This takes into account that the string is an ASCIIZ string ( Zero Terminate ASCII String), if not you will need to know the string's length. If you have any issues understanding how to preform this, I suggest taking it up with your professor and he might be able to explain how the instructions work a bit better.

Bryant Keller
Posted on 2006-03-21 13:45:16 by Synfire
When you figure it out, try writing it using MMX. It'll be MUCH faster. padd is your friend.

As the above guys said, a stirng is just a collection of bytes (usually within ASCII range: 32-127) usually zero-terminated (byte '0' is added at the end). Such zero-terminated ASCII string is often reffered to as 'ASCIIZ'.

Please look at the attached image. It may give you some understanding of how bytes are 'interpreted' as characters. Each element in that table is numbered from 0 to 255. 32 is a space character, 33 is ' ! ', 34 is ' " ', ... ..., 64 is '@', 65 is 'A', and so on. Why these numbers and not some other ones? ASCII is just a standard - it could be any different, but the world agreed to write characters THIS way. The last ASCII char is 127 (which usually doesn't have any 'interpretation').
Posted on 2006-03-21 14:36:32 by ti_mo_n
Thanks for the posts guys =]
I understand a lot more about this now.
Well i am the bottom of my class.. so :P
Cheers for helping me out, if i get stuck, i'll let you pros know about it :P
Posted on 2006-03-21 16:51:08 by looter