Module: Itsdangerousr
- Defined in:
- lib/itsdangerousr.rb
Defined Under Namespace
Modules: URLSafeSerializerMixin
Classes: BadPayload, BadSignature, BadTimeSignature, HMACAlgorithm, Serializer, SignatureExpired, Signer, SigningAlgorithm, TimedSerializer, TimestampSigner, URLSafeSerializer, URLSafeTimedSerializer
Constant Summary
collapse
- EPOCH =
1293840000
Class Method Summary
collapse
Class Method Details
.base64_decode(string) ⇒ Object
16
17
18
|
# File 'lib/itsdangerousr.rb', line 16
def self.base64_decode(string)
Base64.urlsafe_decode64(string + '=' * (-string.length % 4))
end
|
.base64_encode(string) ⇒ Object
12
13
14
|
# File 'lib/itsdangerousr.rb', line 12
def self.base64_encode(string)
Base64.urlsafe_encode64(string).gsub(/=+$/, '')
end
|
.constant_time_compare(val1, val2) ⇒ Object
21
22
23
24
25
|
# File 'lib/itsdangerousr.rb', line 21
def self.constant_time_compare(val1, val2)
check = val1.bytesize ^ val2.bytesize
val1.bytes.zip(val2.bytes) { |x, y| check |= x ^ y.to_i }
check == 0
end
|