Encrypt-DecryptSyntaxeEncrypt(string_cle, string_text) Decrypt(string_cle, string_text) Deux routines jumelles pour crypter et décrypter un texte. Les paramètres et le résultat sont au format texte. string_cle est la clé de cryptage, string_text le texte à crypter ou décrypter. Le cryptage utilise la méthode de Vigenère mais au lieu d'un carré de 26X26, utilise un carré de 224 X 224 = les 256 caractères ASCII moins les 32 premiers qui sont des caractères système non exploitables. Adaptation d'un script de Krysec ecrit en "PowerBuilder" publié dans Hackerz Voice n°10 mai 2002. ExempleEncrypt("Lucky", "Joe Dalton") ---> "vÄ®kùç¡·º«" Decrypt("Lucky", "vÄ®kùç¡·º«") ---> "Joe Dalton" Scripton Encrypt(string_cle, string_text) set j to 1 set code to "" repeat with i from 1 to the length of string_text set var_text to ASCII number (character i of string_text) set var_cle to ASCII number (character j of string_cle) if var_text < 32 then set code to code + (ASCII character (var_text)) else set code to code & (ASCII character (((var_text + var_cle - 64) mod 224) + 32)) end if set j to (1 + j mod (length of string_cle)) end repeat return code end Encrypt
on Decrypt(string_cle, string_text) set j to 1 set texte to "" repeat with i from 1 to the length of string_text set var_code to ASCII number (character i of string_text) set var_cle to ASCII number (character j of string_text) if var_code < 32 then set texte to texte + (ASCII character (var_code)) else set k to (var_code - var_cle) mod 224 if k >= 0 then set texte to texte & (ASCII character (k + 32)) else set texte to texte & (ASCII character (k + 256)) end if end if set j to (1 + j mod (length of string_cle)) end repeat return texte end Decrypt
RemarqueLa méthode de cryptage de Vigenère est expliquée dans le livre "Histoire des codes secrets" de Simon Singh. Pour avoir une securité absolue, la clé doit être dénuée de sens, sa longueur doit être égale à la longueur du message et elle doit être utilisée une seule fois.
|