All Samples(127) | Call(120) | Derive(0) | Import(7)
getrandbits(k) -> x. Generates a long int with k random bits.
src/r/e/REST-Client-HEAD/sample/webapi/auth/oauth.py REST-Client(Download)
import hmac import urllib from hashlib import sha1 from random import getrandbits from time import time from google.appengine.api import urlfetch
def addSignature(self, url, params, method='GET'):
oauth_params = {u'oauth_consumer_key': self._consumer_key,
u'oauth_signature_method': 'HMAC-SHA1',
u'oauth_timestamp': int(time()),
u'oauth_nonce': getrandbits(64),
u'oauth_version': self.version}
if self._access_token!= None:
src/p/y/PyOpenGL-Demo-3.0.1b1/PyOpenGL-Demo/GLUT/glutplane.py PyOpenGL-Demo(Download)
import sys from OpenGL.GLUT import * from OpenGL.GLU import * from OpenGL.GL import * from math import * from random import random, choice, randint, getrandbits
def add_plane():
for i in range(MAX_PLANES) :
if (planes[i].speed == 0.0) :
planes[i].red, planes[i].green, planes[i].blue = choice(rgblist)
planes[i].speed = (float(randint(0, 19)) * 0.001) + 0.02
if (getrandbits(32) & 0x1) :
planes[i].speed *= -1
src/p/u/pugbot-HEAD/pugdata.py pugbot(Download)
from base64 import b64encode from random import getrandbits from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Integer, String, Table from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import relationship from sqlalchemy.sql.expression import func from sys import stderr
def gen_steam_vcode(self):
""" Generates a tag + random 6 character verification code for the user. """
r = getrandbits(8 * 8)
b = pack('<Q', r)
code = b64encode(b[:6])
self.steam_vcode = "[pugbot:%s]" % (code)
return self.steam_vcode
src/p/y/pydouban-HEAD/pydouban/__init__.py pydouban(Download)
import urllib import httplib from hashlib import sha1 from random import getrandbits from time import time from cgi import escape
'oauth_consumer_key': self._key,
'oauth_signature_method': 'HMAC-SHA1',
'oauth_timestamp': int(time()),
'oauth_nonce': getrandbits(64),
'oauth_version': '1.0'}
if self._token:
oauth_params['oauth_token'] = self._token
src/w/e/web2con-HEAD/web2con/oauth.py web2con(Download)
from .auth import Auth from time import time from random import getrandbits from time import time import urllib import hashlib
params['oauth_signature_method'] = 'HMAC-SHA1'
params['oauth_version'] = '1.0'
params['oauth_timestamp'] = str(int(time()))
params['oauth_nonce'] = str(getrandbits(64))
enc_params = urlencode_noplus(sorted(params.iteritems()))
src/t/w/twitter-1.4.2/twitter/oauth.py twitter(Download)
from twitter.auth import Auth from time import time from random import getrandbits from time import time import urllib import hashlib
params['oauth_signature_method'] = 'HMAC-SHA1'
params['oauth_version'] = '1.0'
params['oauth_timestamp'] = str(int(time()))
params['oauth_nonce'] = str(getrandbits(64))
enc_params = urlencode_noplus(sorted(params.iteritems()))
src/l/i/libs-HEAD/cream/util/__init__.py libs(Download)
def random_hash(bits=100, hashfunction='sha256'):
from random import getrandbits
import hashlib
return getattr(hashlib, hashfunction)(str(getrandbits(bits))).hexdigest()