def roll_die(num_sides, true_random=False): '''simulates rolling a die, if true_random is set, it will use random.org to produce true random numbers. be careful though, it might take a lot of time and the difference is really not that much.''' if true_random is True: import randomdotorg r = randomdotorg.RandomDotOrg('alimsvi.ir') return r.randrange(1, num_sides + 1) return random.randrange(1, num_sides + 1)
def random_number_generator(self, n): """ :Parameters: n : int number of random bytes to be generated :Return: a string of n bytes of random number generated using random.org """ r = randomdotorg.RandomDotOrg('RSAKeyGenerator') return str(hex(r.getrandbits(n * 8)))[2:]
import randomdotorg import wave import struct r = randomdotorg.RandomDotOrg('UnifyID') print r.get_quota() # 8kHz * 8bit * 3 = ~= 200,000 bits framerate = 8000 numFrames = 3 * framerate outfile = wave.open('noise.wav', 'w') outfile.setnchannels(1) outfile.setsampwidth(1) outfile.setframerate(framerate) outfile.setnframes(numFrames) data = [] for i in range(numFrames/200): data += r.randrange(0, 2**8, amount=200) for datum in data: outfile.writeframesraw(struct.pack('<B', datum)) outfile.writeframes('') outfile.close()
# Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Pyhole Russian Roulette Plugin""" try: import randomdotorg random = randomdotorg.RandomDotOrg() except ImportError: import random from pyhole import plugin class RussianRoulette(plugin.Plugin): """Provide access to dice games""" def __init__(self, *args, **kwargs): super(RussianRoulette, self).__init__(*args, **kwargs) self.game = None def _gun(self, size=6): chamber = [0] * (size - 1) chamber.append(1)
decrypted = "" i = 0 for letter in message: decrypted += Offset(letter, -key[i]) i += 1 return decrypted code = -863520 message = "The krabby patty secret formula is nothing." encryptedMessage = (Caesar(message, code)) decryptedMessage = DeCaesar(encryptedMessage, code) print("Caesar Cypher: ") print("Original Message: " + message) print("Encrypted Message: " + encryptedMessage) print("Decrypted Message: " + decryptedMessage) r = randomdotorg.RandomDotOrg('encrypter.py') key = r.randrange(97, 122, 1, len(message)) # print ("\n" "Key: ") # print (key) # Don't show this to anyone! encryptedMessage = OneTimePadEncrypt(message, key) decryptedMessage = OneTimePadDecrypt(encryptedMessage, key) print("\n" + "One Time Pad: ") print("Original Message: " + message) print("Encrypted Message: " + encryptedMessage) print("Decrypted Message: " + decryptedMessage) key = [] # Get rid of the key once it's used.
def getRandomNumber(low, high): print 'getting number from random.org between ', low, 'and', high r = randomdotorg.RandomDotOrg() return r.randrange(low, high)