• 🏆 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!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

Names Binds

Status
Not open for further replies.
Level 3
Joined
Oct 2, 2013
Messages
27
is there a way to bind a name to a code to replace a hero with another hero and only that player may use that code to replace that hero?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,233
is there a way to bind a name to a code to replace a hero with another hero and only that player may use that code to replace that hero?
Yes, it is a common part of all save/load systems.

The simplest implementation is to save a "hash" of the player name as an element inside the code. Since code length is important you can merge the player name hash with the code checksum. This is usually done with xor operation however due to WC3 lacking that you can get away with addition (which is similar in many ways).

The result is that if a player with a different account name uses the code the checksum does not match up with the payload so the load attempt can be rejected as "corrupted".

Alternatively you can use the account name as part of an encryption process for similar results. If the wrong account uses the code it will decrypt to garbage and so the checksum will fail to match so the code can be rejected as corrupted.

You push the user name through the string hash function (I think it has something to do with "key" in GUI, but basically it is a native string hasher). The output is a full range 32bit which is deterministic based on input and is case-insensitive (so does support player name case changes at the battlenet login screen). This is often too large for codes that do not need strong protection so you can shorten it by either dividing or modulating by an appropriate amount. Best protection needs all 32 bits of information however, anything less runs high chances of collisions.

For extra security add secret keys and other reversible transformations to both the code checksum and the player name hash. These make it less apparent that standard algorithms are in use and so harder to crack without resorting to reverse engineering.
 
Level 3
Joined
Oct 2, 2013
Messages
27
Yes, it is a common part of all save/load systems.

The simplest implementation is to save a "hash" of the player name as an element inside the code. Since code length is important you can merge the player name hash with the code checksum. This is usually done with xor operation however due to WC3 lacking that you can get away with addition (which is similar in many ways).

The result is that if a player with a different account name uses the code the checksum does not match up with the payload so the load attempt can be rejected as "corrupted".

Alternatively you can use the account name as part of an encryption process for similar results. If the wrong account uses the code it will decrypt to garbage and so the checksum will fail to match so the code can be rejected as corrupted.

You push the user name through the string hash function (I think it has something to do with "key" in GUI, but basically it is a native string hasher). The output is a full range 32bit which is deterministic based on input and is case-insensitive (so does support player name case changes at the battlenet login screen). This is often too large for codes that do not need strong protection so you can shorten it by either dividing or modulating by an appropriate amount. Best protection needs all 32 bits of information however, anything less runs high chances of collisions.

For extra security add secret keys and other reversible transformations to both the code checksum and the player name hash. These make it less apparent that standard algorithms are in use and so harder to crack without resorting to reverse engineering.

Is there a tutorial on how to do that?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,233
Something like would work.
JASS:
set udg_intvar = StringHash(GetPlayerName(Player(0)))
It sets the global GUI integer variable intvar to the hash of the player name of the first player (usually red).

You can then use that integer with your save/load system like any other integer.
 
Status
Not open for further replies.
Top