IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VB 6 et antérieur Discussion :

Crypter données dans fichier random


Sujet :

VB 6 et antérieur

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    22
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 22
    Points : 16
    Points
    16
    Par défaut Crypter données dans fichier random
    Bonjour
    Lorsque je crée un fichier à accès direct, les données apparaissent en clair dans mon fichier.dat, on peut donc les voir avec Notepad (ou autre...)directement. Je souhaiterais que ce fichier soit crypté, ou au moins en hexadécimal pour éviter une consultation si facile. L'accès à mon application est elle même protégée par un mot de passe.
    voici une partie du code:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    '---------ouverture du fichier
    Private Sub Form_Load()
    Open "C:\Windows\System32\sysco.dat" For Random As #1 Len = 300
    End Sub
    '---------lecture du fichier
    For index = 1 To nbr
    Get 1, index, enr
    '
    service = enr.service
    passe = enr.passe
    texteInfo1 = enr.texteInfo1
    info1 = enr.info1
    texteInfo2 = enr.texteInfo2
    info2 = enr.info2
    texteInfo3 = enr.texteInfo3
    info3 = enr.info3
     
    '-----------affichage liste
    index = Format(index, "000")
    List1.AddItem index & "    " & service
    Next index
    List1.ListIndex = List1.ListCount - 1
    End Sub
     '--------- fin affichage liste
     
    '--------écriture dans le fichier
    Private Sub Command2_Click()
    enr.service = Text1.Text
    enr.passe = Text3.Text
    enr.texteInfo1 = Text4.Text
    enr.info1 = Text5.Text
    enr.texteInfo2 = Text6.Text
    enr.info2 = Text7.Text
    enr.texteInfo3 = Text8.Text
    enr.info3 = Text9.Text
    enr.divers = Text10.Text
    Put 1, index, enr
    '---------------------------
    d'avance je vous remercie d'examiner mon problème...
    bien amicalement
    rolby

  2. #2
    Membre éprouvé Avatar de DAUDET78
    Homme Profil pro
    retraité
    Inscrit en
    Janvier 2008
    Messages
    634
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 81
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2008
    Messages : 634
    Points : 1 161
    Points
    1 161
    Par défaut
    Citation Envoyé par rolby65 Voir le message
    Je souhaiterais que ce fichier soit crypté,
    on va retourner à Enigma !
    ou au moins en hexadecimal
    Dans ton fichier, c'est de l'hexa ..... que malheureusement NotePad interprète en ASCII

    Si tu veux un simple camouflage ....
    Tu fais une table de 256 octets avec Ramdom
    Tu fais un OUexclusif du caractère avec le premier caractère de la table
    Tu écris ce caractère dans le fichier
    Et tu recommences avec le caractère suivant (modulo 256) de la table

    L'opération inverse en lecture te redonne le fichier d'origine

  3. #3
    Membre à l'essai
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    22
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 22
    Points : 16
    Points
    16
    Par défaut merci daudet ... mais
    bonjour Daudet78
    merci pour ta reponse, mais mon niveau de connaissances en VB est débutant et donc je ne sais pas du tout faire ce dont tu me parles. je me demandais si dans la ligne de code qui ouvre le fichier, il n'y aurait pas par exemple un parametre à ajouter pour crypter ?
    si tu souhaites, je peux te poster la totalite du code de mon application ...
    bien amicalement
    rolby65

  4. #4
    Membre éprouvé Avatar de DAUDET78
    Homme Profil pro
    retraité
    Inscrit en
    Janvier 2008
    Messages
    634
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 81
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2008
    Messages : 634
    Points : 1 161
    Points
    1 161
    Par défaut
    Citation Envoyé par rolby65 Voir le message
    il n'y aurait pas par exemple un parametre à ajouter pour crypter ?
    A mon humble connaissance , ce n'est pas prévu ...... au programme !
    Par contre, sur le WEB tu dois trouver des exemples de programme de cryptage beaucoup plus sophistiqués

    PS : Tu ne sais pas faire un OUexclusif entre une chaine de caractères et une table de caractères ?

  5. #5
    Membre éprouvé Avatar de DAUDET78
    Homme Profil pro
    retraité
    Inscrit en
    Janvier 2008
    Messages
    634
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 81
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2008
    Messages : 634
    Points : 1 161
    Points
    1 161
    Par défaut
    C'est ce programme que tu veux faire (en pièce jointe). C'est un vieux truc que j'ai fait il y a 10 ans !

    Dans fichier, tu rentres
    - le chemin du fichier à convertir
    - le chemin du futur fichier crypté
    - le chemin du futur fichier décrypté

    Tu cliques sur le bouton Cryptage
    Tu cliques sur le bouton DéCryptage
    Tu cliques sur le bouton Fin


    Tu constates que le fichier crypté est en chinois
    Tu constates que le fichier décrypté est identique au fichier d'origine
    Fichiers attachés Fichiers attachés

  6. #6
    Membre à l'essai
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    22
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 22
    Points : 16
    Points
    16
    Par défaut cryptage fichier .dat
    bonjour Daudet78,
    en effet ton programme crypt fait exactement ce que je voudrais faire. Je suppose qu'il faut :
    - crypter mon fichier dés le départ,
    - ensuite le décrypter pour lire ou entrer des données,
    - puis le recrypter ,
    - et enfin, effacer le fichier décrypté, avant de quitter l'application.
    Il reste maintenant à intégrer ton application à mon code ...est-ce possible?... ou plutôt, est ce possible pour moi?...
    en tout cas merci pour ta patience avec le débutant que je suis.
    Bien amicalement
    Rolby

    Voici le code complet de mon appli :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    '------début du code-------------
    Private Sub Command1_Click()
    End
    End Sub
     
    Private Sub Command2_Click()
    enr.service = Text1.Text
    enr.passe = Text3.Text
    enr.texteInfo1 = Text4.Text
    enr.info1 = Text5.Text
    enr.texteInfo2 = Text6.Text
    enr.info2 = Text7.Text
    enr.texteInfo3 = Text8.Text
    enr.info3 = Text9.Text
    enr.divers = Text10.Text
    Put 1, index, enr
    '--------------affichage liste
       List1.Clear
    nbr = (LOF(1) / 300)
    index = nbr + 1
     ''''''''
     
    For index = 1 To nbr
    Get 1, index, enr
    '
    service = enr.service
    passe = enr.passe
    texteInfo1 = enr.texteInfo1
    info1 = enr.info1
    texteInfo2 = enr.texteInfo2
    info2 = enr.info2
    texteInfo3 = enr.texteInfo3
    info3 = enr.info3
     
    '
    index = Format(index, "000")
    List1.AddItem index & "    " & service
    Next index
    List1.ListIndex = List1.ListCount - 1
       '--------- fin affichage liste
     
       Command2.Visible = True
    Text1.Locked = True
     Text3.Locked = True
    Text4.Locked = True
    Text5.Locked = True
     Text6.Locked = True
     Text7.Locked = True
     Text8.Locked = True
     Text9.Locked = True
     Text10.Locked = True
    Command2.Visible = False
    List1.SetFocus
    End Sub
     
     
    Private Sub Command3_Click()
    Text1.Text = ""
     
     
     Text3.Text = ""
    Text4.Text = ""
    Text5.Text = ""
     Text6.Text = ""
     
     Text7.Text = ""
     Text8.Text = ""
     Text9.Text = ""
     Text10.Text = ""
     
     Text1.SetFocus
    End Sub
     
    Private Sub Command4_Click()
    Static res
    res = MsgBox("                vous en êtes VRAIEMENT sûr de vouloir  ? ...", 1 + 256 + 48, "....   Vous etes sur le point d'effacer la fiche n°" & index & " " & service & "...")
    If res = 1 Then
     
     Text1.Text = "*"
     Text3.Text = ""
     Text4.Text = ""
     Text5.Text = ""
     Text6.Text = ""
     Text7.Text = ""
     Text8.Text = ""
     Text9.Text = ""
     Text10.Text = ""
     
    enr.service = Text1.Text
    enr.passe = Text3.Text
    enr.texteInfo1 = Text4.Text
    enr.info1 = Text5.Text
    enr.texteInfo2 = Text6.Text
    enr.info2 = Text7.Text
    enr.texteInfo3 = Text8.Text
    enr.info3 = Text9.Text
    enr.divers = Text10.Text
    Put 1, index, enr
    End If
     
    Dim indexT%
    indexT% = 1
    '------- ouvre fichier temporaire
    Open "Tempor.dat" For Random As #2 Len = 300
    '------- fin ouvre fichier temporaire
    '------ lit fichier existant
    nbr = LOF(1) / 300
    For index = 1 To nbr
        Get 1, index, enr
    '--------
    service = enr.service
    passe = enr.passe
    texteInfo1 = enr.texteInfo1
    info1 = enr.info1
    texteInfo2 = enr.texteInfo2
    info2 = enr.info2
    texteInfo3 = enr.texteInfo3
    info3 = enr.info3
    divers = enr.divers
     
    '--------
    If Trim$(service) <> "*" Then
     Put 2, indexT%, enr   ' quand champ est différent de * , ecrit dans fichier temporaire
          indexT% = indexT% + 1 ' avec nouvel index
    End If
     
    Next index
       Close 1
      Close 2
     Kill "C:\Windows\System32\sysco.dat"
    Name "tempor.dat" As "C:\Windows\System32\sysco.dat"  ' renomme le fichier tempor en FICHIER
    '''''''''
    Open "C:\Windows\System32\sysco.dat" For Random As #1 Len = 300 'ouvre le nouveau fichier tempor
     
    '--- afficher liste à jour
     '--------------affichage liste
       List1.Clear
    nbr = (LOF(1) / 300)
    index = nbr + 1
     ''''''''
     
    For index = 1 To nbr
    Get 1, index, enr
    '
    service = enr.service
    passe = enr.passe
    texteInfo1 = enr.texteInfo1
    info1 = enr.info1
    texteInfo2 = enr.texteInfo2
    info2 = enr.info2
    texteInfo3 = enr.texteInfo3
    info3 = enr.info3
     
    '
    index = Format(index, "000")
    List1.AddItem index & "    " & service
    Next index
    List1.ListIndex = List1.ListCount - 1
       '--------- fin affichage liste
     
     
     
    End Sub
     
    Private Sub Command6_Click()
    Dim msg
    msg = "   N'interrompez pas l'opération de réorganisation," & Chr(10) & Chr(10)
    msg = msg & "vous perdriez irrémédiablement le fichier  ' RESERVE ' ..."
     
    MsgBox msg, 48
    Dim indexT%
    indexT% = 1
    '------- ouvre fichier temporaire
    Open "Tempor.dat" For Random As #2 Len = 300
    '------- fin ouvre fichier temporaire
    '------ lit fichier existant
    nbr = LOF(1) / 300
    For index = 1 To nbr
        Get 1, index, enr
    '--------
    service = enr.service
    passe = enr.passe
    texteInfo1 = enr.texteInfo1
    info1 = enr.info1
    texteInfo2 = enr.texteInfo2
    info2 = enr.info2
    texteInfo3 = enr.texteInfo3
    info3 = enr.info3
    divers = enr.divers
     
    '--------
    If Trim$(service) <> "*" Then
     Put 2, indexT%, enr   ' quand champ est différent de * , ecrit dans fichier temporaire
          indexT% = indexT% + 1 ' avec nouvel index
    End If
     
    Next index
       Close 1
      Close 2
     Kill "C:\Windows\System32\sysco.dat"
    Name "tempor.dat" As "C:\Windows\System32\sysco.dat"  ' renomme le fichier tempor en FICHIER
    '''''''''
    Open "C:\Windows\System32\sysco.dat" For Random As #1 Len = 300 'ouvre le nouveau fichier tempor
     
    '--- afficher liste à jour
     '--------------affichage liste
       List1.Clear
    nbr = (LOF(1) / 300)
    index = nbr + 1
     ''''''''
     
    For index = 1 To nbr
    Get 1, index, enr
    '
    service = enr.service
    passe = enr.passe
    texteInfo1 = enr.texteInfo1
    info1 = enr.info1
    texteInfo2 = enr.texteInfo2
    info2 = enr.info2
    texteInfo3 = enr.texteInfo3
    info3 = enr.info3
     
    '
    index = Format(index, "000")
    List1.AddItem index & "    " & service
    Next index
    List1.ListIndex = List1.ListCount - 1
       '--------- fin affichage liste
     
     
     
     
    End Sub
     
    Private Sub Form_Activate()
    Text12.SetFocus
    End Sub
     
    Private Sub Form_Load()
    Open "C:\Windows\System32\sysco.dat" For Random As #1 Len = 300
     
    End Sub
     
     
    Private Sub List1_Click()
     
    index = Val(List1.ListIndex) + 1
    Get 1, index, enr
    '---
    service = enr.service
    passe = enr.passe
    texteInfo1 = enr.texteInfo1
    info1 = enr.info1
    texteInfo2 = enr.texteInfo2
    info2 = enr.info2
    texteInfo3 = enr.texteInfo3
    info3 = enr.info3
    divers = enr.divers
    '---
    Text1.Text = service
    Text3.Text = passe
    Text4.Text = texteInfo1
    Text5.Text = info1
    Text6.Text = texteInfo2
    Text7.Text = info2
    Text8.Text = texteInfo3
    Text9.Text = info3
    Text10.Text = divers
    '---
    End Sub
     
    Private Sub menu1_Click()
    Text1.Locked = False
     Text3.Locked = False
    Text4.Locked = False
    Text5.Locked = False
     Text6.Locked = False
     Text7.Locked = False
     Text8.Locked = False
     Text9.Locked = False
     Text10.Locked = False
     
     
    Text1.Text = ""
     Text3.Text = ""
    Text4.Text = ""
    Text5.Text = ""
     Text6.Text = ""
     
     Text7.Text = ""
     Text8.Text = ""
     Text9.Text = ""
     Text10.Text = ""
     
     Text1.SetFocus
     
    End Sub
     
    Private Sub menu2_Click()
    Command2.Visible = True
    Text1.Locked = False
     Text3.Locked = False
    Text4.Locked = False
    Text5.Locked = False
     Text6.Locked = False
     Text7.Locked = False
     Text8.Locked = False
     Text9.Locked = False
     Text10.Locked = False
     
    End Sub
     
    Private Sub menu3_Click()
    nbr = (LOF(1) / 300)
    index = nbr + 1
    enr.service = Text1.Text
    enr.passe = Text3.Text
    enr.texteInfo1 = Text4.Text
    enr.info1 = Text5.Text
    enr.texteInfo2 = Text6.Text
    enr.info2 = Text7.Text
    enr.texteInfo3 = Text8.Text
    enr.info3 = Text9.Text
    enr.divers = Text10.Text
    Put 1, index, enr
    '---
    List1.Clear
    nbr = (LOF(1) / 300)
    index = nbr + 1
     ''''''''
     
    For index = 1 To nbr
    Get 1, index, enr
    '
    service = enr.service
    passe = enr.passe
    texteInfo1 = enr.texteInfo1
    info1 = enr.info1
    texteInfo2 = enr.texteInfo2
    info2 = enr.info2
    texteInfo3 = enr.texteInfo3
    info3 = enr.info3
    divers = enr.divers
     
    '
    index = Format(index, "000")
    List1.AddItem index & "    " & service
    Next index
    List1.ListIndex = List1.ListCount - 1
    '---
    '--------------affichage liste
       List1.Clear
    nbr = (LOF(1) / 300)
    index = nbr + 1
     ''''''''
     
    For index = 1 To nbr
    Get 1, index, enr
    '
    service = enr.service
    passe = enr.passe
    texteInfo1 = enr.texteInfo1
    info1 = enr.info1
    texteInfo2 = enr.texteInfo2
    info2 = enr.info2
    texteInfo3 = enr.texteInfo3
    info3 = enr.info3
     
    '
    index = Format(index, "000")
    List1.AddItem index & "    " & service
    Next index
    List1.ListIndex = List1.ListCount - 1
       '--------- fin affichage liste
     
       Command2.Visible = True
    Text1.Locked = True
     Text3.Locked = True
    Text4.Locked = True
    Text5.Locked = True
     Text6.Locked = True
     Text7.Locked = True
     Text8.Locked = True
     Text9.Locked = True
     Text10.Locked = True
    Command2.Visible = False
    List1.SetFocus
    End Sub
     
    Private Sub menu4_Click()
    Static res
    res = MsgBox("                vous en êtes VRAIEMENT sûr de vouloir  ? ...", 1 + 256 + 48, "....   Vous etes sur le point d'effacer la fiche n°" & index & " " & service & "...")
    If res = 1 Then
     
     Text1.Text = "*"
     Text3.Text = ""
     Text4.Text = ""
     Text5.Text = ""
     Text6.Text = ""
     Text7.Text = ""
     Text8.Text = ""
     Text9.Text = ""
     Text10.Text = ""
     
    enr.service = Text1.Text
    enr.passe = Text3.Text
    enr.texteInfo1 = Text4.Text
    enr.info1 = Text5.Text
    enr.texteInfo2 = Text6.Text
    enr.info2 = Text7.Text
    enr.texteInfo3 = Text8.Text
    enr.info3 = Text9.Text
    enr.divers = Text10.Text
    Put 1, index, enr
    End If
     
    Dim indexT%
    indexT% = 1
    '------- ouvre fichier temporaire
    Open "Tempor.dat" For Random As #2 Len = 300
    '------- fin ouvre fichier temporaire
    '------ lit fichier existant
    nbr = LOF(1) / 300
    For index = 1 To nbr
        Get 1, index, enr
    '--------
    service = enr.service
    passe = enr.passe
    texteInfo1 = enr.texteInfo1
    info1 = enr.info1
    texteInfo2 = enr.texteInfo2
    info2 = enr.info2
    texteInfo3 = enr.texteInfo3
    info3 = enr.info3
    divers = enr.divers
     
    '--------
    If Trim$(service) <> "*" Then
     Put 2, indexT%, enr   ' quand champ est différent de * , ecrit dans fichier temporaire
          indexT% = indexT% + 1 ' avec nouvel index
    End If
     
    Next index
       Close 1
      Close 2
     Kill "C:\Windows\System32\sysco.dat"
    Name "tempor.dat" As "C:\Windows\System32\sysco.dat"  ' renomme le fichier tempor en FICHIER
    '''''''''
    Open "C:\Windows\System32\sysco.dat" For Random As #1 Len = 300 'ouvre le nouveau fichier tempor
     
    '--- afficher liste à jour
     '--------------affichage liste
       List1.Clear
    nbr = (LOF(1) / 300)
    index = nbr + 1
     ''''''''
     
    For index = 1 To nbr
    Get 1, index, enr
    '
    service = enr.service
    passe = enr.passe
    texteInfo1 = enr.texteInfo1
    info1 = enr.info1
    texteInfo2 = enr.texteInfo2
    info2 = enr.info2
    texteInfo3 = enr.texteInfo3
    info3 = enr.info3
     
    '
    index = Format(index, "000")
    List1.AddItem index & "    " & service
    Next index
    List1.ListIndex = List1.ListCount - 1
       '--------- fin affichage liste
     
     
    End Sub
     
    Private Sub Text12_Change()
    Dim longueurpasse
    longueurpasse = Len(Text12.Text)
    If Text12.Text = "7377" Then
        Text1.Visible = True
     
        Text2.Visible = True
        Text3.Visible = True
        Text4.Visible = True
        Text5.Visible = True
        Text6.Visible = True
        Text7.Visible = True
        Text8.Visible = True
        Text9.Visible = True
        Text10.Visible = True
        List1.Visible = True
        Command1.Visible = True
     
     
        Label1.Visible = False
        Text12.Visible = False
     
       'affichage liste
       List1.Clear
    nbr = (LOF(1) / 300)
    index = nbr + 1
     ''''''''
     
    For index = 1 To nbr
    Get 1, index, enr
    '
    service = enr.service
    passe = enr.passe
    texteInfo1 = enr.texteInfo1
    info1 = enr.info1
    texteInfo2 = enr.texteInfo2
    info2 = enr.info2
    texteInfo3 = enr.texteInfo3
    info3 = enr.info3
     
    '
    index = Format(index, "000")
    List1.AddItem index & "    " & service
    Next index
    List1.ListIndex = List1.ListCount - 1
       '---------
       Else
     
      If longueurpasse = 4 Then
     
        Text1.Visible = False
        Text2.Visible = False
        Text3.Visible = False
        Text4.Visible = False
        Text5.Visible = False
        Text6.Visible = False
        Text7.Visible = False
        Text8.Visible = False
        Text9.Visible = False
        Label1.Visible = True
        Text12.Visible = True
        Text12.Text = ""
     
    End If
    End If
    End Sub
    '----------fin du code-------------

  7. #7
    Membre éprouvé Avatar de DAUDET78
    Homme Profil pro
    retraité
    Inscrit en
    Janvier 2008
    Messages
    634
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 81
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2008
    Messages : 634
    Points : 1 161
    Points
    1 161
    Par défaut
    Voila la routine de cryptage
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
            Call Alea(45)
            Open FichierOUT$ For Binary As #2
            Open FichierIN$ For Binary As #1
            LL& = FileLen(FichierIN$)
            While LL& >= BlocRead&
                Get #1, , Buf$
                Put #2, , Buf$
                LongFile& = LongFile& - BlocRead&
                DoEvents
                LL& = LL& - BlocRead&
            Wend
            If LL& > 0 Then
                Buf$ = Space$(LL&)
                Get #1, , Buf$
                For I% = 1 To Len(Buf$)
                    S$ = Mid$(Buf$, I%, 1)
                    J% = Asc(S$) Xor (Rnd * 1000000 And &HFF&)
                    Mid$(Buf$, I%, 1) = Chr$(J% And &HFF)
                Next I%
                Put #2, , Buf$
                LongFile& = LongFile& - LL&
            End If
            Close
    et de décryptage
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
          Call Alea(45)
            Open FichierTST$ For Binary As #3
            Open FichierOUT$ For Binary As #2
            LL& = FileLen(FichierOUT$)
            While LL& >= BlocRead&
                Get #2, , Buf$
                Put #3, , Buf$
                LongFile& = LongFile& - BlocRead&
                DoEvents
                LL& = LL& - BlocRead&
            Wend
            If LL& > 0 Then
                Buf$ = Space$(LL&)
                Get #2, , Buf$
                For I% = 1 To Len(Buf$)
                    S$ = Mid$(Buf$, I%, 1)
                    J% = Asc(S$) Xor (Rnd * 1000000 And &HFF&)
                    Mid$(Buf$, I%, 1) = Chr$(J% And &HFF)
                Next I%
                Put #3, , Buf$
                LongFile& = LongFile& - LL&
            End If
            Close
    et l'initialisation
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    Sub Alea(Valeur%)
        Rnd (-1)
        Randomize (Valeur%)
    End Sub
    la valeur de 45 qui est passée par l'appelant détermine une séquence aléatoire identique à chaque appel

  8. #8
    Membre à l'essai
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    22
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 22
    Points : 16
    Points
    16
    Par défaut routine cryptage
    bonjour Daudet78,
    je te remercie bien pour ta réponse, c'est bien ce qu'il me faut. A moi de jouer maintenant pour bien exploiter cette routine...
    Merci encore pour ton aide.
    Bien amicalement
    rolby65

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 12
    Dernier message: 04/01/2007, 17h31
  2. lire données dans fichier txt
    Par flo456 dans le forum Langage
    Réponses: 5
    Dernier message: 14/09/2006, 08h01
  3. [pl/sql] Récupérer des données dans fichier
    Par claralavraie dans le forum Oracle
    Réponses: 22
    Dernier message: 13/07/2006, 16h49
  4. [DOM XML] Insertion données dans fichier XML avec PHP pour Flash ?
    Par ExSter dans le forum Bibliothèques et frameworks
    Réponses: 17
    Dernier message: 10/05/2006, 11h16
  5. Sauvegarde de données dans fichier csv
    Par issou dans le forum C
    Réponses: 1
    Dernier message: 22/12/2005, 08h36

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo