This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> primos = [] | |
| >>> for i in xrange(1, 1000): | |
| resultado = miller(i) | |
| if resultado: | |
| primos.append(i) | |
| >>> print primos | |
| [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997] | |
| >>> len(primos) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import math | |
| import random | |
| def sd(m): | |
| s = 1 | |
| d = 0 | |
| while True: | |
| d = int(m / math.pow(2, s)) | |
| if d % 2 == 0: # Hay que evaluar si el numero que multiplica es par o impar |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| plaintext = archivo.read() | |
| klone = keyone.read().splitlines() | |
| kltwo = keytwo.read().splitlines() | |
| llaveuno = klone[0] | |
| llavedos = kltwo[0] | |
| ciphertext = [] | |
| #Encriptar el "plaintext" | |
| for i, caracter in enumerate(plaintext): | |
| cipher = ord(llaveuno[i % len(llaveuno)]) ^ ord(caracter) | |
| ciphertext.append(unichr(cipher)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import codecs | |
| def xorcipher(filename, fkeyone, fkeytwo): | |
| try: | |
| archivo = codecs.open(filename, 'r', 'utf-8') | |
| keyone = codecs.open(fkeyone, 'r', 'utf-8') | |
| keytwo = codecs.open(fkeytwo, 'r', 'utf-8') | |
| except IOError, e: | |
| print 'Error al abrir alguno de los archivos' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import random | |
| import codecs | |
| def generador(numero, longitud): | |
| numero = int(numero) | |
| longitud = int(longitud) | |
| llaves = [] | |
| i = 0 | |
| while i < numero: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def generador(numero, longitud): | |
| numero = int(numero) | |
| longitud = int(longitud) | |
| llaves = [] | |
| i = 0 | |
| while i < numero: | |
| llave = [] | |
| j = 0 | |
| while j < longitud: | |
| temp = random.randrange(33, 126) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| filename = sys.argv[1] | |
| abc = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] | |
| file = open(filename, 'r') | |
| texto = file.read() | |
| file.close() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| conteos = [] | |
| porcentaje = [] | |
| total = 0 | |
| for letter in abc: | |
| conteo = 0 | |
| for l in texto: | |
| if(letter == l): | |
| conteo += 1 | |
| total += conteo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| if len(sys.argv) > 2: | |
| if sys.argv[1] == 'file': | |
| file = open(sys.argv[2], 'r') | |
| mensaje = file.read() | |
| file.close() | |
| else: | |
| mensaje = sys.argv[1] |
NewerOlder