How can I filter out profanity in base36 IDs?

此生再无相见时 提交于 2019-12-22 07:08:32

问题


I want to use base36 in a web application I am developing... but as the id is visible to users as a url, I want to filter out profanity. Has anyone solved this? Or is this even a real problem?

Does it make sense just to skip numbers in my database sequence?


回答1:


Well, rather than try to amass all the swear words possible, just filter out the vowels. That'll leave you plenty of permutations in the space. Admittedly, you've just cut down from base 36 to base 31, but base 31 numbers are valid base 36 numbers assuming the same symbol set (a-z0-9). IF that bothers you, replace the five vowels with some other non-magic 7-bit ascii like !,@,$,% and (.

Granted, you may end up with sh1t and fck, but the profanity is in the mind of the reader.




回答2:


Why not just use a full-on randomly generated GUID in hexadecimal? No matter what programming language you're working in, this should be easy to generate. And being represented in hexadecimal, I would imagine the chances of generating something that upsets the easily offendable approach zero.



来源:https://stackoverflow.com/questions/5032310/how-can-i-filter-out-profanity-in-base36-ids

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!