51 routines :

*AppleScriptsVanilla*
ascii_to_HTML
Average
Calculator
Calendar
Count_item
cut_text
days_week
EAN13
Encrypt-Decrypt
FactPremier
French_Vanilla_Dotted_Date
French_Vanilla_Dotted_Date2
Hexa_to_Bin
Last_month
list_erase
list_insert
list_replace
ListeDiviseurs
ListePremiers
Minuscule
NombreLong
NombreLong2
NomExtension
num_item
num_month
num_month2
num_week
number_format
number_format2
Paques
PGCD
PGCD2
reverse_string
Roman_to_Arab
round_decimal
search_email
search_replace
search_URL
SepNbre
SepNbre2
snip_text
stat
TauxPermut
TauxTransform
the_left
the_right
TriBulle
TriLineaire
week_and_year
XOR
ZeroDouble

Encrypt-Decrypt

Syntaxe

Encrypt(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.

Exemple

Encrypt("Lucky", "Joe Dalton")
---> "vÄ®kùç¡·º«"
Decrypt("Lucky", "vÄ®kùç¡·º«")
---> "Joe Dalton"

Script

on 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

Remarque

La 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.

Site scripté avec HyperCard ©1987-1998 Apple Computer, Inc.
Mise à jour le 19/01/10 à 08:45:57