Module: Crypto_math

### Home Classes Methods

### In Files

- lib/openid/util.rb

### Methods

- #mod_exp

### Class/Module Index

Quicksearch

- OpenID
- OpenID::Association
- OpenID::AssociationManager
- OpenID::AuthenticationError
- OpenID::BaseAssociationManager
- OpenID::Consumer
- OpenID::ConsumerAssociation
- OpenID::DiffieHelmanAssociator
- OpenID::DumbAssociationManager
- OpenID::NoArgumentsError
- OpenID::NoOpenIDArgs
- OpenID::ProtocolError
- OpenID::Request
- OpenID::Response
- OpenID::ServerAssociation
- OpenID::SimpleHTTPClient
- OpenID::UserCancelled
- OpenID::UserSetupNeeded
- OpenID::ValueMismatchError
- String
- String::OpenID
- Bignum
- Crypto_math
- DateTime
- Fixnum

No matching classes.

# Crypto_math

Functions convenient for cryptography

### Public Instance Methods

mod_exp(n,q) click to toggle source

This code is taken from this post by Eric Lee Green. x.mod_exp(n,q) returns x ** n % q

    # File lib/openid/util.rb, line 12
    def mod_exp(n,q)
            counter=0
            n_p=n  # N

            y_p=1        # Y

            z_p=self  # Z

            while n_p != 0
            if n_p[0]==1
                            y_p=(y_p*z_p) % q
            end
            n_p = n_p >> 1
            z_p = (z_p * z_p) % q
            counter += 1
    end
    return y_p
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.