Posted 01 October 2012 - 05:15 PM
Hi,
I'm currently working on some kind of keycard system.
It currently consists of two parts, a keycard writer to create keycards and a reader to read them.
Basically i have a key for example: "aaaaaBBBBBcccccDDDDDeeeee"
this key has a variable length depending on access level
Level A has the full 25 character long key.
Level E has only the first five characters.
To enter a Level E Area with a Level A card I use substring to get the first 5 chars:
sLevelKey = the key generated from the card to compare with the master key for this station
sKey = the full key from the card
iLevel = security level of the station
iLevelLength = the length of each security segment (in our case constantly 5)
this code from the writer returns a valid string as it should:
sWriteKey = the key to be written on the keycard
sMKey = the masterkey to get the new key from
iLevel = security level of the keycard
iLevelLength = the length of each security segment (in our case constantly 5)
I'm currently working on some kind of keycard system.
It currently consists of two parts, a keycard writer to create keycards and a reader to read them.
Basically i have a key for example: "aaaaaBBBBBcccccDDDDDeeeee"
this key has a variable length depending on access level
Level A has the full 25 character long key.
Level E has only the first five characters.
To enter a Level E Area with a Level A card I use substring to get the first 5 chars:
sLevelKey = the key generated from the card to compare with the master key for this station
sKey = the full key from the card
iLevel = security level of the station
iLevelLength = the length of each security segment (in our case constantly 5)
sLevelKey = string.sub(sKey, iLevel*iLevelLength, iLevelLength)
this code in the card reader returns an empty string (not nil)this code from the writer returns a valid string as it should:
sWriteKey = the key to be written on the keycard
sMKey = the masterkey to get the new key from
iLevel = security level of the keycard
iLevelLength = the length of each security segment (in our case constantly 5)
sWriteKey = string.sub(sMKey, 1, iLevel*iLevelLength)
I checked all values in both cases and they are what they have to be to make this method work but apparently it doesn't like me :|