Base16

Algorithme utilisé par Up ! System

L'algorithme Base16 de l'Internet Engineering Task Force (IETF) permet d'encoder un flux binaire en un flux texte transformant un octet en deux caractères alphabétiques.

Son principe est le suivant :

La taille de la ligne ne doit pas dépasser 76 caractères une fois encodée. Une ligne non encodée peut être découpée en plusieurs lignes encodées.

Le saut de ligne est représenté par les deux caractères successifs saut de ligne \n et retour chariot \r non encodés.

Table d'encodage

Code décimal.Code hexadécimal.Caractère.
0000x000
0010x011
0020x022
0030x033
0040x044
0050x055
0060x066
0070x077
0080x088
0090x099
0100x0AA
0110x0BB
0120x0CC
0130x0DD
0140x0EE
0150x0FF

Exemple d'un flux encodé l'algorithme Base16

Flux non encodé

/* ------------------------------------------------------------------- */ /* Fichier : clientftp.upl */ /* Objet : Exemple d'emploi d'Up ! Network. */ /* */ /* Module : Up ! Application System. */ /* Auteur-Date : DUVAL Jean-Pierre - Novembre 2003. */ /* ------------------------------------------------------------------- */ /* Observations */ /* */ /* */ /* ------------------------------------------------------------------- */ Source Composant "Exemple d'emploi d'Up ! Network" Version 4.0.0; ImporterModule UpsFts(, ImporterDefinitions); Variable /******/ MonServeur : Nul Ou ServeurFtp; Principal /*******/ Debut MonServeur=ServeurFtp("ftp://local:21"); MonServeur.ChangerConnexion("anonymous", "contact@mon-domaine.com"); MonServeur.ChangerEtatTypeDonnees(TypeDonneesAscii); CopierFichier("C:/tmp2/essai.txt", "ftp://local:21/tmp/essai.txt"); MonServeur.ChangerEtatTypeDonnees(TypeDonneesImage); CopierFichier("UpsFts://local:21/tmp/essai.doc", "C:/tmp2/essai.doc"); MonServeur=Nul; Fin Principal

Flux encodé

2F2A202D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D 2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D202A2F0A 2F2A2046696368696572202020203A20636C69656E746674702E75706C2020202020202020 202020202020202020202020202020202020202020202020202020202020202020202A2F0A 2F2A204F626A65742020202020203A204578656D706C65206427656D706C6F692064275570 2021204E6574776F726B2E20202020202020202020202020202020202020202020202A2F0A 2F2A2020202020202020202020202020202020202020202020202020202020202020202020 202020202020202020202020202020202020202020202020202020202020202020202A2F0A 2F2A204D6F64756C652020202020203A2055702021204170706C69636174696F6E20537973 74656D2E20202020202020202020202020202020202020202020202020202020202A2F0A2F 2A204175746575722D44617465203A20445556414C204A65616E2D506965727265202D204E 6F76656D62726520323030332E20202020202020202020202020202020202020202A2F0A2F 2A202D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D 2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D202A2F0A2F 2A20202020202020202020202020202020202020202020202020204F62736572766174696F 6E73202020202020202020202020202020202020202020202020202020202020202A2F0A2F 2A202020202020202020202020202020202020202020202020202020202020202020202020 2020202020202020202020202020202020202020202020202020202020202020202A2F200A 2F2A2020202020202020202020202020202020202020202020202020202020202020202020 202020202020202020202020202020202020202020202020202020202020202020202A2F20 0A2F2A202D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D 2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D202A2F 0A0A536F7572636520436F6D706F73616E7420224578656D706C65206427656D706C6F6920 642755702021204E6574776F726B222056657273696F6E20312E322E303B0A0A496D706F72 7465724D6F64756C65200A202020557073467470283C5570734674703E2C20496D706F7274 6572446566696E6974696F6E73293B0A0A5661726961626C650A2F2A2A2A2A2A2A2F0A2020 204D6F6E53657276657572203A204E756C204F7520536572766575724674703B0A0A507269 6E636970616C0A2F2A2A2A2A2A2A2A2F0A44656275740A4D6F6E536572766575723D536572 7665757246747028225570734674703A2F2F6C6F63616C3A323122293B0A0A4D6F6E536572 766575722E4368616E676572436F6E6E6578696F6E2822616E6F6E796D6F7573222C202263 6F6E746163744075702D636F6D702E636F6D22293B0A4D6F6E536572766575722E4368616E 6765724574617454797065446F6E6E6565732854797065446F6E6E6565734173636969293B 0A436F70696572466963686965722822433A2F746D70322F65737361692E747874222C2022 5570734674703A2F2F6C6F63616C3A32312F746D702F65737361692E74787422293B0A4D6F 6E536572766575722E4368616E6765724574617454797065446F6E6E656573285479706544 6F6E6E656573496D616765293B0A436F706965724669636869657228225570734674703A2F 2F6C6F63616C3A32312F746D702F65737361692E646F63222C2022433A2F746D70322F6573 7361692E646F6322293B0A4D6F6E536572766575723D4E756C3B0A46696E205072696E6369 70616C0A0A