rebol [ title: "crypto" version: 1.0 date: 01/09/2003 author: "Sébastien 'Jedi' Jeudy" email: s.jeudy@libertysurf.fr url: http://reboleur.free.fr ] cryptage: does [ ; données nom-fichier: ask "Nom du fichier texte à crypter : " nom-fichier-crypt: ask "Nom du fichier texte crypté : " nom-fichier-cle: ask "Nom du fichier texte clé : " fichier: read to-file nom-fichier cle: read to-file nom-fichier-cle ; cryptage print "Cryptage..." fichier-crypt: "" pos-cle: 1 for pos-fichier 1 (length? fichier) 1 [ car-asc: (to-integer to-binary fichier/:pos-fichier) + (to-integer to-binary cle/:pos-cle) if car-asc > 255 [ car-asc: car-asc - 255 ] fichier-crypt: join fichier-crypt (to-char car-asc) pos-cle: pos-cle + 1 if pos-cle > (length? cle) [ pos-cle: 1 ] ] write to-file nom-fichier-crypt fichier-crypt ] decryptage: does [ ; données nom-fichier: ask "Nom du fichier texte à décrypter : " nom-fichier-decrypt: ask "Nom du fichier texte décrypté : " nom-fichier-cle: ask "Nom du fichier texte clé : " fichier: read to-file nom-fichier cle: read to-file nom-fichier-cle ; décryptage print "Décryptage..." fichier-decrypt: "" pos-cle: 1 for pos-fichier 1 (length? fichier) 1 [ car-asc: (to-integer to-binary fichier/:pos-fichier) - (to-integer to-binary cle/:pos-cle) if car-asc < 0 [ car-asc: car-asc + 255 ] fichier-decrypt: join fichier-decrypt (to-char car-asc) pos-cle: pos-cle + 1 if pos-cle > (length? cle) [ pos-cle: 1 ] ] write to-file nom-fichier-decrypt fichier-decrypt ] print "CRYPTO" choix: ask "Cryptage [c] ou Décryptage [d] ? " if any [ (choix = "c") (choix = "C") ] [ cryptage ] if any [ (choix = "d") (choix = "D") ] [ decryptage ] print "Terminé."