mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-11-15 01:11:23 +00:00
Removed for githubs sake
This commit is contained in:
parent
cd2c421f0f
commit
93e49c74ba
1 changed files with 0 additions and 41 deletions
|
@ -1,45 +1,4 @@
|
|||
module Verification
|
||||
def Verification.verify input
|
||||
md5 = Digest::MD5.hexdigest("9WvcZ9hX" + input + "KF7L4luQ").upcase.split(//)
|
||||
chars = ["A", "B", "C", "D", "E", "F"]
|
||||
nums = []
|
||||
lastPos = md5[31].to_i
|
||||
result = ""
|
||||
|
||||
for i in 0..9
|
||||
pos = md5[i].to_i
|
||||
|
||||
if pos == 0
|
||||
pos = lastPos ** (i % 4)
|
||||
elsif (pos % 4) == 0
|
||||
pos = pos * lastPos + i
|
||||
elsif (pos % 3) == 0
|
||||
pos = pos ** (i % 4)
|
||||
elsif (pos % 2) == 0
|
||||
pos = pos * i + pos
|
||||
end
|
||||
|
||||
pos = (pos > 31) ? (pos % 32) : pos
|
||||
curChar = md5[31 - pos]
|
||||
curNum = curChar.to_i
|
||||
|
||||
if nums.include? curNum
|
||||
if curNum == 0
|
||||
curChar = chars[pos % 6]
|
||||
else
|
||||
curChar = (pos % 10).to_s
|
||||
end
|
||||
curNum = curChar.to_i
|
||||
end
|
||||
|
||||
nums << curNum
|
||||
result << curChar
|
||||
lastPos = pos
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
def Verification.uncrap str
|
||||
str.to_s.gsub(/[^A-Za-z0-9_\-]/, "")
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue