• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

encrypt code

Status
Not open for further replies.
Level 4
Joined
Jul 28, 2004
Messages
43
HI, im trying to make a trigger to save/load only 'players wood' and a variable, but i dont know how to encrypt the code, ive tryed to read manual, i follow the paths, but it doesnt run!!! plz help me
 
Level 7
Joined
Jul 30, 2004
Messages
451
Manukiller said:
HI, im trying to make a trigger to save/load only 'players wood' and a variable, but i dont know how to encrypt the code, ive tryed to read manual, i follow the paths, but it doesnt run!!! plz help me

i don't know much about encryption, but if ur just using a number have u tried multiplying it by a prime number and then using modolo to convert it to a non-10-base numbering system?
 
Level 4
Joined
Jul 28, 2004
Messages
43
emergenzy

yeah, but i need to encrypt numbers between 0-2000, and i dont want to do 2000 equivalences, it must run by separate into 4 numbers, using mathematics?,ah, can u copy by a test your equvialences(2=q, 2=3 ...)?to have an idea
 
Level 2
Joined
Aug 15, 2004
Messages
18
I think you can break up a number into its digits with modulo somehow, but I forgot how. You could also do it by taking the number, dividing it by thousand, and rounding down. Then you have the thousands digit. Substract the thousands from the number, then divide by 100 and round down. You get the 100s digit. And so on.

Example:
number to break up into digits = 1763
1763/1000=1.763, rounded down = 1 //thousands digit
1763-1000=763
763/100=7.63, rounded down = 7 //hundreds digit
763-700=63
63/10=6.3, rounded down = 6 //tens digit
63-60=3 //ones digit

There probably is a more easy way, but I cant think of it now.


Of course you dont need all this. Just do some kind of calculation with the number, like multiplying with a random prime number out of a selection of ten prime numbers and assigning a digit to every prime number. 2 = 4, 3 = 6, 5 = 0, 7 = and so on. Put that digit on a fixed place in the code. Like for example the fifth digit of the code designates what it was multiplied by. To save it in the middle of the code you would have to break the code up into single digits, though. If you want to put it to the end of the code its very simple, just multiply the code by ten and add the digit, so if you don't want to do the work of breaking the code up do it that way. If you want to put it somewhere to the middle of the code youd have to make sure the code has at least the number of digits you want to put your key digit to, though.

Example:
The number you want to save is 79
The prime number that was chosen is 3
79*3 = 237
key digit for 3 = 6
Lets assume you want to put the key digit to the third digit in your code.
After doing the above procedure you get the digits 2, 3 and 7.
Now you put them back together, but with 6 as the third digit.
You get the code 2367

The problem is that this way your code doesnt have a fixed length, and all codes are valid, so its not a very good encryption, at least not if more wood = better. People would eventually notice that more wood means longer code and just add a few digits to the end of the code. Another problem is that its hard to save multiple numbers if the code doesnt have a fixed number of digits. You would need to use some kind of seperator, which again decreases the safety of the code.
With setting letters as equivalents to digits not every code is valid, so it is harder to cheat. It's more work, though.
 
Level 7
Joined
Jul 30, 2004
Messages
451
letter equivilents are pretty bad for security i mean, if u get 22 kills, ur code will look like XX or something

needless to say iwouldn't suggest any encryption unless it has mathematical security that will deter random type-ins
 
Status
Not open for further replies.
Top