PlayfulGuy wrote: ↑Sat Oct 19, 2024 1:39 pm
I'm traveling right now and have limited time so can't put together a demo, but look at the ascii code table and how the characters map to numbers. For example, the ascii code for A is 65, B is 66, etc, and then lower case letters start at 97.
If you use A as 0, then you code each value to a string as
Code: Select all
text = String.fromCharCode(value+65)
If value is 0 this would give A. If value is 10 this would give K.
I would make an encode function like
Code: Select all
function encode(value) {
if ( value >= 0 && value <= 57 ) return String.fromCharCode(value+65)
else return "@" // @ means undefined
}
Which would give you an uppercase or lowercase letter, or one of the few characters in between those sets (open square bracket, close square bracket etc)
Code: Select all
// And then use
password = encode(value1)
password += encode(value2)
password += encode(value3)
// etc ...
If value1 = 3, value2 = 7 and value3 = 10 this would give you password = "DHK".
This supports values from 0 to 58, and encodes it as one character per value.
Then you decode it with a function like
Code: Select all
function decode(password,index) {
// If the character is "@" the value was out of range
// Return value is undefined if index is beyond end of string, or value was out of range
if ( index < password.length && password.charAt(index) != "@" ) {
return password.charCodeAt(index) - 65
}
return undefined
}
value1 = decode(password,0)
value2 = decode(password,1)
value3 = decode(password,2)
// etc...
None of that is tested but it should be pretty close and give you the idea.
PG
Looks very promising. Thanks for all the help. I'll try, as soon as I get time to work on it.
undeniable_denial wrote: ↑Sat Oct 19, 2024 6:44 pm
I think it would be helpful if you clarified the needed datatypes and maximum length/range of the variables. We could then more easily think of an adequate way to encode it into a short string. There are many possibilities.
This is what's need to be locked into a password:
var girl = teaseStorage.getItem("girl") || [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] //each one can be a number between 0 and 5
var block = teaseStorage.getItem("block") || [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0] //each only 0 or 1
var vin = teaseStorage.getItem("vin") || [0,0,0,0,0,0,0,0,0] //each only 0 or 1
var vincount = teaseStorage.getItem("vincount") || 0 //0-9
var jiu = teaseStorage.getItem("jiu") || 0 //0 or 1
var chap = teaseStorage.getItem("chap") || 0 //0 or 1
var prog = teaseStorage.getItem("prog") || 0 //consecutive numbering
var Donnawin = teaseStorage.getItem("Donnawin") || 0 //consecutive numbering
var GDonnawin = teaseStorage.getItem("GDonnawin") || 0 //0 or 1
var FantasyDeny = teaseStorage.getItem("FantasyDeny") || 0 //0 or 1
var AeryRuin = teaseStorage.getItem("AeryRuin") || 0 //0 - 4
var footfetisch = teaseStorage.getItem("footfetisch") || 0 //0 or 1
var faktor = teaseStorage.getItem("faktor") || 1
var holdfaktor = teaseStorage.getItem("holdfaktor") || 1.4
var holdmore = teaseStorage.getItem("holdmore") || 0 // 0 or 1
var BreathHold = teaseStorage.getItem("BreathHold") || 0
var LJoyceFirst = teaseStorage.getItem("LJoyceFirst") || 0 //0 or 1
var donnainf = teaseStorage.getItem("donnainf") || 0 // 0 or 1
var AliceOutfit = teaseStorage.getItem("AliceOutfit") || 0 // 0 - 3
var NAlice = teaseStorage.getItem("NAlice") || 0 // 0 - 3
//for the following: each can be 0 or 1
var dkeep = teaseStorage.getItem("dkeep") || [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
var gkeep = teaseStorage.getItem("gkeep") || [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
var jkeep = teaseStorage.getItem("jkeep") || [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
var lkeep = teaseStorage.getItem("lkeep") || [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
var nkeep = teaseStorage.getItem("nkeep") || [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
var rum0 = teaseStorage.getItem("rum0") || [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
var rum1 = teaseStorage.getItem("rum1") || [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
var rum2 = teaseStorage.getItem("rum2") || [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
var rum3 = teaseStorage.getItem("rum3") || [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
var rum4 = teaseStorage.getItem("rum4") || [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
var rum5 = teaseStorage.getItem("rum5") || [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
var rum6 = teaseStorage.getItem("rum6") || [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
var rum7 = teaseStorage.getItem("rum7") || [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
var rum8 = teaseStorage.getItem("rum8") || [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
var pim = teaseStorage.getItem("pim") || [0,0,0,0,0,0,0]
var dim = teaseStorage.getItem("dim") || [0,0,0,0,0]
var um = teaseStorage.getItem("um") || [0,0,0,0,0,0,0,0,0]