Module: OpenID::CryptUtil

Module | OpenID::CryptUtil
In: | lib/openid/cryptutil.rb

This module contains everything needed to perform low-level cryptograph and data manipulation tasks.

### Methods

base64_to_num binary_to_num hmac_sha1 hmac_sha256 num_to_base64 num_to_binary rand random_string sha1 sha256

### Public Class methods

base64_to_num(s)

Decode a base64 byte string to a number.

binary_to_num(s)

Convert a string of bytes into a number.

hmac_sha1(key, text)
hmac_sha256(key, text)
num_to_base64(l)

Encode a number as a base64-encoded byte string.

num_to_binary(n)

Convert a number to its binary representation; return a string of bytes.

rand(max)

Generate a random number, doing a little extra work to make it more likely that it‘s suitable for cryptography. If your system doesn‘t have /dev/urandom then this number is not cryptographically safe. See <www.cosine.org/2007/08/07/security-ruby-kernel-rand/> for more information. max is the largest possible value of such a random number, where the result will be less than max.

random_string(length, chars=nil)

Generate a random string of the given length, composed of the specified characters. If chars is nil, generate a string composed of characters in the range 0..255.

sha1(text)
sha256(text)

[Validate]