#-*-coding:utf8-*- from random import shuffle N = input("Quelle taille pour les blocs ? ") key = range(N) shuffle(key) print "La clé est :",key message = raw_input("Quel message chiffrer ? ") blocs = [message[N*k:N*(k+1)] for k in range(len(message)/N)] crypto = [[blocs[k][u] for u in key] for k in range(len(blocs))] print "Cryptogramme :",''.join(sum(crypto,[]))