This is the secret message:
231039119174222085007179032046174036079006248051046168036095007244038115105222053249179056125176222077006248222129160036085002250222119175234012013003052046168052095008179042124170054012011251032130091051084248179042115180222085007193222085170046080179253046112092
This is the working code:
# Asterik Encryption v1.7 # By Magnie # Credit if used. :D def crypt(text, key): # This takes the ascii value of each letter of the key then adds them all together, # then it multiplies that by the length of the key. kord = sum([ord(x) for x in key]) * len(key) cipher_text = '' #i is used to alternate through each letter of the key and use it's ascii value. i = 0 for x in text: # For each letter in the plain_text # Multiply key[i] by length of the text then add the kord value to it then # add the ascii value of letter 'x' cipher_letter = ord(x) + (kord + ord( key[i] ) * len(text)) # Make sure the letter is less than 255 cipher_letter %= 255 cipher_letter = str(cipher_letter) # Make it a string # Make sure each value is in a 3 letter chunk. So if the value is 9, change it # to 009. while len(cipher_letter) != 3: # Add a zero to the front cipher_letter = '0'+cipher_letter # Add the number to the end of the cipher_text cipher_text += cipher_letter # Switch to the next letter in the key. i = (i+1) % len(key) # Return the cipher_text to the script. return int(cipher_text) def decrypt(text, key): try: number = int(text) # Is it crypted text? Since crypted text is only numbers kord = sum([ord(x) for x in key]) * len(key) plain_text = [] except ValueError: return 'Not encrypted.' cipher_chunk = '' i = 0 for x in text: cipher_chunk += x i = (i+1) % 3 if i == 0: plain_text.append(cipher_chunk) cipher_chunk = '' decrypted = '' i = 0 for x in plain_text: decrypt = int(x) - (kord + ord( key[i] ) * len(plain_text)) while decrypt < 0: decrypt += 255 decrypted += chr(decrypt) i = (i+1) % len(key) return decrypted if __name__ == "__main__": while True: text = raw_input("Text: ") key = raw_input("Key: ") type = raw_input("(E)ncrypt or (D)ecrypt: ") if type.lower() == 'e': print crypt(text, key) elif type.lower() == 'd': #for i in xrange(97, 122): #key = chr(i) print decrypt(text, key)
CheeseMonkey: The encryption code for the other one didn't encrypt the message correctly. Making it virtually impossible to decrypt.
Last edited by Magnie (2012-02-23 18:24:03)
Offline
Magnie wrote:
CheeseMunchy: The encryption code for the other one didn't encrypt the message correctly. Making it virtually impossible to decrypt.
ya I mentioned that it the encrypter I used before was different.
Here, does this work?:
=:##{1<_:6_*3[<_:6_*3[444
Last edited by CheeseMunchy (2012-02-23 18:34:10)
Offline
CheeseMunchy wrote:
Magnie wrote:
CheeseMunchy: The encryption code for the other one didn't encrypt the message correctly. Making it virtually impossible to decrypt.
ya I mentioned that it the encrypter I used before was different.
Here, does this work?:
=:##{1<_:6_*3[<_:6_*3[444
I meant on my encryption code. The only problem with the decrypter you gave me was that periods were s's and commas were r's.
Offline
I am just starting with scratch, so if anyone could tell me some basics, that would be very appreciated.
Offline
NZPrograms wrote:
I am just starting with scratch, so if anyone could tell me some basics, that would be very appreciated.
Why are you posting this in the Python topic? Scratch and Python are 2 completely different things! I suggest you ask in the Help with Script forum, as there are many Scratchers out there willing to help you.
Offline
SciTecCf wrote:
NZPrograms wrote:
I am just starting with scratch, so if anyone could tell me some basics, that would be very appreciated.
Why are you posting this in the Python topic? Scratch and Python are 2 completely different things! I suggest you ask in the Help with Script forum, as there are many Scratchers out there willing to help you.
So sorry, I meant python.
Offline
Please help this does not work!
code:
import random
dn = 1
l = 2
while dn == 1:
print " I am thinking of a number between 1 and" , l, ", which number is it"
t = for i in xrange(1):
yield random.randint(1, l)
r = input("answer:")
if r == t:
print "Correct"
l = l+1
else:
print "Wrong"
print "your score was" ,l-1, "points. Thanks for playing!"
dn = 0
What did I do wrong?
Offline
playzooki wrote:
Please help this does not work!
code:
import random
dn = 1
l = 2
while dn == 1:
print " I am thinking of a number between 1 and" , l, ", which number is it"
t = for i in xrange(1):
yield random.randint(1, l)
r = input("answer:")
if r == t:
print "Correct"
l = l+1
else:
print "Wrong"
print "your score was" ,l-1, "points. Thanks for playing!"
dn = 0
What did I do wrong?
What error did you get?
Offline
playzooki wrote:
Please help this does not work!
code:
import random
dn = 1
l = 2
while dn == 1:
print " I am thinking of a number between 1 and" , l, ", which number is it"
t = for i in xrange(1):
yield random.randint(1, l)
r = input("answer:")
if r == t:
print "Correct"
l = l+1
else:
print "Wrong"
print "your score was" ,l-1, "points. Thanks for playing!"
dn = 0
What did I do wrong?
Python 2 or 3?
Offline
2.7.2, invalid syntax on for (for was highlighted)
Last edited by playzooki (2012-08-11 14:45:04)
Offline
Bump!
I got bored.
import pygame, sys, random from pygame.locals import * pygame.init() amountOfParticles = 150 pygame.key.set_repeat(1000/30, 1000/30) particles = [] DISPLAYSURF = pygame.display.set_mode((800, 600), 0, 32) pygame.display.set_caption('Christmas Particles') for i in range(amountOfParticles): particles.append([random.randint(1, 799), random.randint(1, 599), random.randint(-1, 1), random.randint(-1, 1), random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)]) while True: DISPLAYSURF.fill((0, 0, 0)) for i in range(len(particles)): pygame.draw.polygon(DISPLAYSURF, (particles[i][4], particles[i][5], particles[i][6]), [(particles[i][0], particles[i][1]), (particles[i][0]+1, particles[i][1]), (particles[i][0]+1, particles[i][1]+1), (particles[i][0], particles[i][1]+1)]) pygame.draw.polygon(DISPLAYSURF, (particles[i][4], particles[i][5], particles[i][6]), [(800 - particles[i][0], particles[i][1]), (800 - particles[i][0]+1, particles[i][1]), (800 - particles[i][0]+1, particles[i][1]+1), (800 - particles[i][0], particles[i][1]+1)]) pygame.draw.polygon(DISPLAYSURF, (particles[i][4], particles[i][5], particles[i][6]), [(particles[i][0], 600 - particles[i][1]), (particles[i][0]+1, 600 - particles[i][1]), (particles[i][0]+1, 600 - particles[i][1]+1), (particles[i][0], 600 - particles[i][1]+1)]) pygame.draw.polygon(DISPLAYSURF, (particles[i][4], particles[i][5], particles[i][6]), [(800 - particles[i][0], 600 - particles[i][1]), (800 - particles[i][0]+1, 600 - particles[i][1]), (800 - particles[i][0]+1, 600 - particles[i][1]+1), (800 - particles[i][0], 600 - particles[i][1]+1)]) particles[i][0] += particles[i][2] particles[i][1] += particles[i][3] particles[i][2] *= 0.999 particles[i][3] *= 0.999 if particles[i][0] > 799 or particles[i][0] < 1: particles[i][2] *= -1 if particles[i][1] > 599 or particles[i][1] < 1: particles[i][3] *= -1 particles[i][4] = (particles[i][4] + 1) % 256 particles[i][5] = (particles[i][5] + 1) % 256 particles[i][6] = (particles[i][6] + 1) % 256 for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() if pygame.mouse.get_pressed()[0] == True: for i in range(len(particles)): xdist = particles[i][0] - pygame.mouse.get_pos()[0] ydist = particles[i][1] - pygame.mouse.get_pos()[1] if xdist > 0: particles[i][2] -= 0.01 else: particles[i][2] += 0.01 if ydist > 0: particles[i][3] -= 0.01 else: particles[i][3] += 0.01 pygame.display.update()
Offline