I am trying to make a function to generate the 6 chars at the end of a bit.ly like link. Since I have a limited number of links to work with I want to grab them linearly, but I dont want to count directly for security reasons. What I have come up with is to have 6 lists of 78 randomized chars and use them for counting. So rather than 000000 being the first link you will still get random numbers and letters because it will be a custom alphabet. That being said I am not a math person so I am having a hard time coming up with a function to turn my 6 strings of chars into a random 6 char string without collisions. This is what I have for now. Right now I am working in nodejs, but if you would prefer a different language I can translate the code over. Forgive my terrible node code. I started in the language last night.
class DataType {
constructor() {
this.intvalue = 0
this.base78 = ""
const first = "pm>*rgOvtWYX4suD2a5T#o1!l^Lhy0z<9f%k\\QAEwKn)x3cVi&SHG7;|]Ue{jIdq(PRCBZ8b6FMN}?"
const second = "aK|SFlDk3>LP2%9ZR<470W6]HwuzdByQM}?U8tC{o^cf!vq&*ixn5bp(#N;mGVOIjXE)YAhs\\egT1r"
const third = "p{iuvQy9fTs?1qMK6EGbSde<\\;25AFc|&mXa^LYljr3N*ZUwxz4%IW])O>nCR7#Pgh0B}oVt8!D(Hk"
const fourth = "!9F{R}*GloeOS?Ex4hAu0T^c8MvZ#IgrH(w7K|]%PnCatbWBLysmkUj\\&iD>)65qfV12YNp3d<zXQ;"
const fifth = "*induo{eI>HgvDy}KRYclsqrx6#WEz!Bm<7w^V(AO&S9NabM2k\\C|3X0?;%4GZ8Pp1Lj]htQT)fUF5"
const sixth = "?aClw6uy>V2Y;g)Svjs0q{D&G|TK#Itf}n9*]U1Oo8Qm(khRiBZ5Wb%cxz!XpdF^e7PA3HLNME<4r\\"
this.decimals = [first, second, third, fourth, fifth, sixth]
}
// returns the next random string
get getNextBase78(){
return this.base78 // 0 would return pap!*? 1 would return map!*?
}
}
Aucun commentaire:
Enregistrer un commentaire