Active Members MrGrj Posted June 2, 2015 Active Members Report Posted June 2, 2015 (edited) Un programel simplu facut in pauza de masa. Enjoy:__author__ = "MrGrj"import binasciidef bas64decryption(): encoded_string = raw_input("Please insert the base64 encrypted text:") decoded_string = encoded_string.decode('base64') if encoded_string is None: print 'You inserted a null string. Please enter a valid string next time !' else: print 'Your decoded string:' + ' ' + decoded_stringdef base64encryption(): decoded_string = raw_input("Please insert the text that you want to encode:") encoded_string = decoded_string.encode('base64') if decoded_string is None: print 'You inserted a null string. Please enter a valid string next time !' else: print 'Your encoded string:' + ' ' + encoded_stringif __name__ == "__main__": menu = {} menu['1'] = "Base 64 decryption." menu['2'] = "Base 64 encryption." menu['3'] = "Exit." while True: options = menu.keys() options.sort() for entry in options: print entry, menu[entry] selection = raw_input("What would you like to do? ") if selection == "1": try: bas64decryption() except binascii.Error: print "This is not a base64 encoded string!" elif selection == "2": try: base64encryption() except binascii.Error: print "Something went wrong! Please try again" elif selection == "3": print "Bye-bye" break else: print "This is not a valid choice !"O sa revin cu update-uri in topicul asta cu alte functii de decoding / encoding. Apoi, cu restul membrilor care stiu python sa facem ceva misto, optimizat, etc. Asta daca se vrea si eu timp. @MasterLight Edited June 2, 2015 by MrGrj Quote
watsonAI Posted June 2, 2015 Report Posted June 2, 2015 O simpla observatie, de ce bas64encryption() decodeaza textul base64 si base64decryption(): il encodeaza? Nu ar trebui sa fie invers numele? Quote
hades Posted June 2, 2015 Report Posted June 2, 2015 M-am tot uitat si nu intelegeam de ce-ai importat binascii pentru asta, tinand cont ca pe stringuri ai functia built-in encode/decode. Apoi am vazut ca e pentru exceptie. Heh, funny. Quote
Active Members MrGrj Posted June 2, 2015 Author Active Members Report Posted June 2, 2015 O simpla observatie, de ce bas64encryption() decodeaza textul base64 si base64decryption(): il encodeaza? Nu ar trebui sa fie invers numele?Da, typo. Thanks @alecseu teoretic asta era ideea sa fac fara nici un import dar arata urat eroarea aia daca bagai un string aiurea Quote
tromfil Posted June 2, 2015 Report Posted June 2, 2015 vezi si pe aici.https://rstforums.com/forum/14053-python-multi-encryption-v1-2-cmin.rst Quote
albastrel Posted June 2, 2015 Report Posted June 2, 2015 @MrGrj bv! daca se poate si unul in 256 Quote