module AadhaarCheck

Constants

D
INV
P
VERSION
ZERO_ORDINAL

Public Class Methods

checksum_digit_of(arg) click to toggle source
# File lib/aadhaar_check.rb, line 32
def self.checksum_digit_of(arg)
  INV[arg.to_s.each_byte.reverse_each.with_index.inject(0) { |check,(x,i)|
    D[check][P[i.next % 8][x - ZERO_ORDINAL]]
  }]
end
valid?(num) click to toggle source
# File lib/aadhaar_check.rb, line 38
def self.valid?(num)
      if num.to_s.length != 12
              return false
      else 
      checksum_digit_of(num.to_s[0..-2]) == num % 10
  end
end