Discuss Python. What are you making in it? what do you need to learn? if so, ask about it!
Offline
I'm sort of developing Soulite which is a Pygame module to keep the Scratch feel of things in Python!
Offline
I've been experimenting with Pyscripter a little lately.
Offline
Agentpieface wrote:
I believe that was the second topic.
----------------------------------------------------------
I'm making translator, and in order to make it I need my program to replace text.
Say I wanted to only replace 5s with 1s and not 55s when I say
variable.replace ("5","1")
I'm a noob to Pyscripter, so can someone tell me how to do that?
Last edited by CheeseMunchy (2012-01-27 22:48:27)
Offline
CheeseMunchy wrote:
Agentpieface wrote:
I believe that was the second topic.
----------------------------------------------------------
No, look at the date of the first posts.
Stick to the first topic!
Offline
Agentpieface wrote:
CheeseMunchy wrote:
Agentpieface wrote:
I believe that was the second topic.
----------------------------------------------------------No, look at the date of the first posts.
Stick to the first topic!
Well if you can get it moved here from Misc, we'll use it.
Offline
CheeseMunchy wrote:
Agentpieface wrote:
CheeseMunchy wrote:
I believe that was the second topic.
----------------------------------------------------------No, look at the date of the first posts.
Stick to the first topic!
Well if you can get it moved here from Misc, we'll use it.
yeah, just realised it's in misc
when i said stick to the first topic misc was still up and running
Last edited by Agentpieface (2012-01-27 17:08:36)
Offline
Bump, anyone who can answer my question?
Offline
CheeseMunchy wrote:
Bump, anyone who can answer my question?
>>> variable = '51515' >>> variable '51515' >>> variable.replace('5', '1') '11111' >>> variable '51515' >>> variable.replace('1', '5') '55555'
or
variable = '51515' print variable print variable.replace('5', '1') print variable.replace('1', '5')
Offline
Magnie wrote:
CheeseMunchy wrote:
Bump, anyone who can answer my question?
Code:
>>> variable = '51515' >>> variable '51515' >>> variable.replace('5', '1') '11111' >>> variable '51515' >>> variable.replace('1', '5') '55555'or
Code:
variable = '51515' print variable print variable.replace('5', '1') print variable.replace('1', '5')
While I was trying to explain my question more clearly to you, in a quote I wrote before this, I answered it for myself by accident. But thanks for getting me thinkin' Magnie. ^^
Last edited by CheeseMunchy (2012-01-28 00:09:43)
Offline
I made my own language!
I dare you too decrypt it. ^^
_:._*3[<_:._*3[1<_=*.<*.<,>_=:,<+)3"<=>><*_<({)#/<-:<@,:__~<+,:>%*3[<=>,/<_{</:|,~@_<_=*."<=>=>=><}~<#>3[)>[:<*.<=*//:3<+,{}<}{/.<({{_2
Last edited by CheeseMunchy (2012-02-22 22:49:27)
Offline
CheeseMunchy wrote:
I made my own language!
I dare you too decrypt it. ^^Code:
_:._*3[<_:._*3[1<_=*.<*.<,>_=:,<+)3"<=>><*_<({)#/<-:<@,:__~<+,:>%*3[<=>,/<_{</:|,~@_<_=*."<=>=>=><}~<#>3[)>[:<*.<=*//:3<+,{}<}{/.<({{_2
Well, according to google, there is no way to find out.
Also, what does this have to do with python?
P.S. I had to put your thing in a code tag because scratch confused it with code from the old block plugin.
Last edited by zippynk (2012-02-22 22:54:05)
Offline
CheeseMunchy wrote:
I made my own language!
I dare you too decrypt it. ^^
_:._*3[<_:._*3[1<_=*.<*.<,>_=:,<+)3"<=>><*_<({)#/<-:<@,:__~<+,:>%*3[<=>,/<_{</:|,~@_<_=*."<=>=>=><}~<#>3[)>[:<*.<=*//:3<+,{}<}{/.<({{_2
You have to give the source-code of the encryption. Cause without the algorithm, it's nearly impossible to decode for newbies like us in the forums.
Another reason people might not crack your ciphertext is that you haven't provided enough of it. It only takes a moment's thought to realise that the more ciphertext the attacker has, the easier it is for him to attack it. Giving would-be attackers just a little ciphertext and then crowing when they can't/don't crack it may be fun, but if you then draw the conclusion that your cipher is attack-proof, you could just end up in trouble if you start to trust it to protect lots of data. Consider, for example, a simple polyalphabetic cipher - give the attacker six bytes of plaintext, and he'll ignore it as a waste of time. Give him sixty bytes, though, and he might just crack it. Give him six hundred, and he'll crack it easily. And even a simple letter to a friend could easily take up a thousand or more bytes.
Yet another reason that some people might not crack your ciphertext is that you haven't explained how the algorithm works. Now, some people have the not unreasonable notion that keeping the algorithm secret improves security. Oddly enough, though, it doesn't. (There is an exception to this rule which I'll come to in a minute, which turns out not to be an exception after all.) Here's why a secret algorithm damages security:
As we have seen, it is sometimes possible to figure out key aspects of the algorithm just by inspecting the ciphertext. For example, a frequency analysis can generally tell us whether a monoalphabetic cipher has been used, or perhaps a transposition cipher. A Kasiski attack can show us whether a simple polyalphabetic cipher is in use. So, just because you don't tell people what the algorithm is, that doesn't necessarily mean they can't figure it out anyway.
If your cipher is more complex, though, it may not be possible to decrypt your ciphertext without knowing the algorithm in advance; but consider this: if it's that complicated, you've almost certainly written a computer program to do the encryption and decryption. So anyone who cares enough about your ciphertext can get at the algorithm, even if it means breaking into your home and ghosting your hard disk whilst you're out shopping or at work or at school or something. If that sounds like overkill, it just means you can't think of any reason why anyone would care enough to do it - which, for most if not all of us - is probably fair enough. Nevertheless, if you have BIG secrets to hide, your level of "justifiable paranoia" ought to increase in proportion.
If it matters enough, people will find out. The British, for example, managed to get hold of the design of the military version of the Enigma machine because the French found a guy in the Chiffrierstelle in 1931 (when Germany was not at war) who was prepared to sell them some vital documents which made this design clear; the French didn't care enough to do anything about it, so they gave it to the Poles, who made lots of progress against Enigma before they ran out of time and handed all they had to the British. So trying to keep your algorithm secret doesn't actually work. Indeed, the Germans realised this. In their security assessments of Enigma, they rightly started with the basic assumption that the enemy (the British) would find a way to get hold of an Enigma machine.
http://s13.zetaboards.com/Crypto/topic/123696/1
Last edited by Magnie (2012-02-22 23:16:24)
Offline
Magnie wrote:
CheeseMunchy wrote:
I made my own language!
I dare you too decrypt it. ^^
_:._*3[<_:._*3[1<_=*.<*.<,>_=:,<+)3"<=>><*_<({)#/<-:<@,:__~<+,:>%*3[<=>,/<_{</:|,~@_<_=*."<=>=>=><}~<#>3[)>[:<*.<=*//:3<+,{}<}{/.<({{_2You have to give the source-code of the encryption. Cause without the algorithm, it's nearly impossible to decode for newbies like us in the forums.
Another reason people might not crack your ciphertext is that you haven't provided enough of it. It only takes a moment's thought to realise that the more ciphertext the attacker has, the easier it is for him to attack it. Giving would-be attackers just a little ciphertext and then crowing when they can't/don't crack it may be fun, but if you then draw the conclusion that your cipher is attack-proof, you could just end up in trouble if you start to trust it to protect lots of data. Consider, for example, a simple polyalphabetic cipher - give the attacker six bytes of plaintext, and he'll ignore it as a waste of time. Give him sixty bytes, though, and he might just crack it. Give him six hundred, and he'll crack it easily. And even a simple letter to a friend could easily take up a thousand or more bytes.
Yet another reason that some people might not crack your ciphertext is that you haven't explained how the algorithm works. Now, some people have the not unreasonable notion that keeping the algorithm secret improves security. Oddly enough, though, it doesn't. (There is an exception to this rule which I'll come to in a minute, which turns out not to be an exception after all.) Here's why a secret algorithm damages security:
As we have seen, it is sometimes possible to figure out key aspects of the algorithm just by inspecting the ciphertext. For example, a frequency analysis can generally tell us whether a monoalphabetic cipher has been used, or perhaps a transposition cipher. A Kasiski attack can show us whether a simple polyalphabetic cipher is in use. So, just because you don't tell people what the algorithm is, that doesn't necessarily mean they can't figure it out anyway.
If your cipher is more complex, though, it may not be possible to decrypt your ciphertext without knowing the algorithm in advance; but consider this: if it's that complicated, you've almost certainly written a computer program to do the encryption and decryption. So anyone who cares enough about your ciphertext can get at the algorithm, even if it means breaking into your home and ghosting your hard disk whilst you're out shopping or at work or at school or something. If that sounds like overkill, it just means you can't think of any reason why anyone would care enough to do it - which, for most if not all of us - is probably fair enough. Nevertheless, if you have BIG secrets to hide, your level of "justifiable paranoia" ought to increase in proportion.
If it matters enough, people will find out. The British, for example, managed to get hold of the design of the military version of the Enigma machine because the French found a guy in the Chiffrierstelle in 1931 (when Germany was not at war) who was prepared to sell them some vital documents which made this design clear; the French didn't care enough to do anything about it, so they gave it to the Poles, who made lots of progress against Enigma before they ran out of time and handed all they had to the British. So trying to keep your algorithm secret doesn't actually work. Indeed, the Germans realised this. In their security assessments of Enigma, they rightly started with the basic assumption that the enemy (the British) would find a way to get hold of an Enigma machine.
http://s13.zetaboards.com/Crypto/topic/123696/1
Yup. ^^
Last edited by CheeseMunchy (2012-02-23 16:30:18)
Offline
zippynk wrote:
CheeseMunchy wrote:
I made my own language!
I dare you too decrypt it. ^^Code:
_:._*3[<_:._*3[1<_=*.<*.<,>_=:,<+)3"<=>><*_<({)#/<-:<@,:__~<+,:>%*3[<=>,/<_{</:|,~@_<_=*."<=>=>=><}~<#>3[)>[:<*.<=*//:3<+,{}<}{/.<({{_2Well, according to google, there is no way to find out.
Also, what does this have to do with python?
P.S. I had to put your thing in a code tag because scratch confused it with code from the old block plugin.
I made the encrypter in python.
Offline
CheeseMunchy wrote:
zippynk wrote:
CheeseMunchy wrote:
I made my own language!
I dare you too decrypt it. ^^Code:
_:._*3[<_:._*3[1<_=*.<*.<,>_=:,<+)3"<=>><*_<({)#/<-:<@,:__~<+,:>%*3[<=>,/<_{</:|,~@_<_=*."<=>=>=><}~<#>3[)>[:<*.<=*//:3<+,{}<}{/.<({{_2Well, according to google, there is no way to find out.
Also, what does this have to do with python?
P.S. I had to put your thing in a code tag because scratch confused it with code from the old block plugin.I made the encrypter in python.
Could you post the encryption code?
Offline
Magnie wrote:
CheeseMunchy wrote:
zippynk wrote:
Well, according to google, there is no way to find out.
Also, what does this have to do with python?
P.S. I had to put your thing in a code tag because scratch confused it with code from the old block plugin.I made the encrypter in python.
Could you post the encryption code?
You mean the program?
Offline
CheeseMunchy wrote:
Magnie wrote:
CheeseMunchy wrote:
I made the encrypter in python.Could you post the encryption code?
You mean the program?
Yes.
Offline
Magnie wrote:
CheeseMunchy wrote:
Magnie wrote:
Could you post the encryption code? :)
You mean the program?
Yes. :)
:O
My code mustn't be uncovered!
:p
Ohh, very well...
plott = raw_input("Well?") satt = plott.replace (',','1') dogo = satt.replace ('?','"') var = dogo.replace ('.','4') thebegginning = var.replace ('!','2') a = thebegginning.replace ('a','>') b = a.replace('b','-') c = b.replace('c','|') d = c.replace('d','/') e = d.replace('e',':') f = e.replace('f','+') g = f.replace('g','[') h = g.replace('h','=') i = h.replace('i','*') j = i.replace('j','^') k = j.replace('k','%') l = k.replace('l','#') m = l.replace('m','}') n = m.replace('n','3') o = n.replace('o','{') p = o.replace('p','@') q = p.replace('q',';') r = q.replace('r','5') s = r.replace('s','6') t = s.replace('t','_') u = t.replace('u',')') v = u.replace('v','&') w = v.replace('w','(') x = w.replace('x','$') y = x.replace('y','~') z = y.replace('z','`') zett = z = z.replace(' ','<') print plott print zett
Oh ya, and the stuff I posted above I used my old faulty system so it won't work well.
Last edited by CheeseMunchy (2012-02-23 18:15:32)
Offline
Yeah, your code is a simple substitution cipher. This one is mine:
91140218033068201122039133145033137195121108152145033137206123108146212019082128080109068234029153128122108137145034140201122051068234029153128110124137228033137196039123140214205148193122122155224032136128106118150227019135212115128069145244147207107039142224016069
# Asterik Encryption v1.6 # 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': print decrypt(text, key)
It's more of a shift-cipher. Oh well.
Edit: Hmm, actually, it's not working.
Last edited by Magnie (2012-02-23 18:17:58)
Offline
Magnie wrote:
Yeah, your code is a simple substitution cipher. This one is mine:
Code:
911402180330682011220391331450331371951211081521450331372061231081462120190821280801090682340291531281221081371450341402011220510682340291531281101241372280331371960391231402142051481931221221552240321361281061181502270191352121151280691452 44147207107039142224016069Code:
# Asterik Encryption v1.6 # 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': print decrypt(text, key)It's more of a shift-cipher. Oh well.
Yaaa. I'm not quite ready to make something like that. :pp
However. I shall get to work on a new language, a much better one.
Last edited by CheeseMunchy (2012-02-23 18:18:26)
Offline
Magnie wrote:
Edit: Hmm, actually, it's not working.
What isn't working?
Offline