Nov 21, 2024

Wiki

Python

Aide

edit SideBar

Search

Vernam

  #-*-coding:utf8-*-
  from random import randint

  def xor(caractere, entier):
      if caractere == str(entier):
          return "0"
      else:
          return "1"

  message = raw_input("Quel texte chiffrer ? ")
  key = [randint(0,1) for k in range(len(message))]
  print "Clé :",key
  crypto = ''.join([xor(message[k],key[k]) for k in range(len(message))])
  print "Cryptogramme :",crypto
  decypher = ''.join([xor(crypto[k],key[k]) for k in range(len(message))])
  print "Déchiffrement :",decypher

Page Actions

Recent Changes

Group & Page

Back Links