mikatit | whitedaymound a écrit :
Bonjour, J'ai crée un petit programme de cryptage qui ressemble à cela :
cript = inputbox ("Entrer votre clé de criptage. Elle doit être différante de zéro." )
mot1 = 110*cript
mot2 = 403*cript
mot3 = 235*cript
mot4 =765*cript
mot5 =456*cript
mot6 =534*cript
mot7 =436*cript
mot8 = 438*cript
mot9 = 997*cript
mot10 =208*cript
mot11 =174*cript
mot12 =578*cript
mot13 =352*cript
mot14 =547*cript
mot15 =848*cript
mot16 =845*cript
mot17 =868*cript
mot18 =777*cript
mot19 =767*cript
mot20 =222*cript
mot21 =223*cript
mot22 =868*cript
mot23 =674*cript
mot24 =407*cript
mot25 =574*cript
mot26 =907*cript
' ----------------------------------------------A----------------------------------------
Const ForReadingA = 1
Const ForWritingA = 2
Set objFSOA = CreateObject("Scripting.FileSystemObject" )
Set objFileA = objFSOA.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForReadingA)
strTextA = objFileA.ReadAll
objFileA.Close
strNewTextA = Replace(strTextA, "a", mot1)
' ----------------------------------------------B----------------------------------------
Const ForReadingB = 1
Const ForWritingB = 2
Set objFSOB = CreateObject("Scripting.FileSystemObject" )
Set objFileB = objFSOB.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForReadingB)
strTextB = objFileB.ReadAll
objFileB.Close
strNewTextB = Replace(strTextB, "b", mot2)
Set objFileB = objFSOB.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForWritingB)
objFileB.WriteLine strNewTextB
objFileB.Close
' ----------------------------------------------C----------------------------------------
Const ForReadingC = 1
Const ForWritingC = 2
Set objFSOC = CreateObject("Scripting.FileSystemObject" )
Set objFileC = objFSOC.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForReadingC)
strTextC = objFileC.ReadAll
objFileC.Close
strNewTextC = Replace(strTextC, "c", mot3)
Set objFileC = objFSOC.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForWritingC)
objFileC.WriteLine strNewTextC
objFileC.Close
' ----------------------------------------------D----------------------------------------
Const ForReadingD = 1
Const ForWritingD = 2
Set objFSOD = CreateObject("Scripting.FileSystemObject" )
Set objFileD = objFSOD.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForReadingD)
strTextD = objFileD.ReadAll
objFileD.Close
strNewTextD = Replace(strTextD, "d", mot4)
Set objFileD = objFSOD.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForWritingD)
objFileD.WriteLine strNewTextD
objFileD.Close
' ----------------------------------------------E----------------------------------------
Const ForReadingE = 1
Const ForWritingE = 2
Set objFSOE = CreateObject("Scripting.FileSystemObject" )
Set objFileE = objFSOE.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForReadingE)
strTextE = objFileE.ReadAll
objFileE.Close
strNewTextE = Replace(strTextE, "e", mot5)
Set objFileE = objFSOE.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForWritingE)
objFileE.WriteLine strNewTextE
objFileE.Close
' ----------------------------------------------F----------------------------------------
Const ForReadingF = 1
Const ForWritingF = 2
Set objFSOF = CreateObject("Scripting.FileSystemObject" )
Set objFileF = objFSOF.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForReadingF)
strTextF = objFileF.ReadAll
objFileF.Close
strNewTextF = Replace(strTextF, "f", mot6)
Set objFileF = objFSOF.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForWritingF)
objFileF.WriteLine strNewTextF
objFileF.Close
' ---------------------------------------------------------------------------------------
' PAUSE POUR LE PROGRAMME
MsgBox "25% éffectué"
' ----------------------------------------------G----------------------------------------
Const ForReadingG = 1
Const ForWritingG = 2
Set objFSOG = CreateObject("Scripting.FileSystemObject" )
Set objFileG = objFSOG.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForReadingG)
strTextG = objFileG.ReadAll
objFileG.Close
strNewTextG = Replace(strTextG, "g", mot7)
Set objFileG = objFSOG.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForWritingG)
objFileG.WriteLine strNewTextG
objFileG.Close
' ----------------------------------------------H----------------------------------------
Const ForReadingH = 1
Const ForWritingH = 2
Set objFSOH = CreateObject("Scripting.FileSystemObject" )
Set objFileH = objFSOH.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForReadingH)
strTextH = objFileH.ReadAll
objFileH.Close
strNewTextH = Replace(strTextH, "h", mot8)
Set objFileH = objFSOH.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForWritingH)
objFileH.WriteLine strNewTextH
objFileH.Close
' ---------------------------------------------I----------------------------------------
Const ForReadingI = 1
Const ForWritingI = 2
Set objFSOI = CreateObject("Scripting.FileSystemObject" )
Set objFileI = objFSOI.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForReadingI)
strTextI = objFileI.ReadAll
objFileI.Close
strNewTextI = Replace(strTextI, "i", mot9)
Set objFileI = objFSOI.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForWritingI)
objFileI.WriteLine strNewTextI
objFileI.Close
' ----------------------------------------------J----------------------------------------
Const ForReadingJ = 1
Const ForWritingJ = 2
Set objFSOJ = CreateObject("Scripting.FileSystemObject" )
Set objFileJ = objFSOJ.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForReadingJ)
strTextJ = objFileJ.ReadAll
objFileJ.Close
strNewTextJ = Replace(strTextJ, "j", mot10)
Set objFileJ = objFSOJ.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForWritingJ)
objFileJ.WriteLine strNewTextJ
objFileJ.Close
' ----------------------------------------------K----------------------------------------
Const ForReadingK = 1
Const ForWritingK = 2
Set objFSOK = CreateObject("Scripting.FileSystemObject" )
Set objFileK = objFSOK.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForReadingK)
strTextK = objFileK.ReadAll
objFileK.Close
strNewTextK = Replace(strTextK, "k", mot11)
Set objFileK = objFSOK.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForWritingK)
objFileK.WriteLine strNewTextK
objFileK.Close
'-----------------------------------L----------------------------------------
Const ForReadingL = 1
Const ForWritingL = 2
Set objFSOL = CreateObject("Scripting.FileSystemObject" )
Set objFileL = objFSOL.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForReadingL)
strTextL = objFileL.ReadAll
objFileL.Close
strNewTextL = Replace(strTextL, "l", mot12)
Set objFileL = objFSOL.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForWritingL)
objFileL.WriteLine strNewTextL
objFileL.Close
' ---------------------------------------------------------------------------------------
' PAUSE POUR LE PROGRAMME
MsgBox "50% éffectué"
' ----------------------------------------------M----------------------------------------
Const ForReadingM = 1
Const ForWritingM = 2
Set objFSOM = CreateObject("Scripting.FileSystemObject" )
Set objFileM = objFSOM.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForReadingM)
strTextM = objFileM.ReadAll
objFileM.Close
strNewTextM = Replace(strTextM, "m", mot13)
Set objFileM = objFSOM.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForWritingM)
objFileM.WriteLine strNewTextM
objFileM.Close
' ----------------------------------------------N----------------------------------------
Const ForReadingN = 1
Const ForWritingN = 2
Set objFSON = CreateObject("Scripting.FileSystemObject" )
Set objFileN = objFSON.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForReadingN)
strTexTN = objFileN.ReadAll
objFileN.Close
strNewTextN = Replace(strTextN, "n", mot14)
Set objFileN = objFSON.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForWritingN)
objFileN.WriteLine strNewTextN
objFileN.Close
' ----------------------------------------------O----------------------------------------
Const ForReadingO = 1
Const ForWritingO = 2
Set objFSOO = CreateObject("Scripting.FileSystemObject" )
Set objFileO = objFSOO.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForReadingO)
strTextO = objFileO.ReadAll
objFileO.Close
strNewTextO = Replace(strTextO, "o", mot15)
Set objFileO = objFSOO.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForWritingO)
objFileO.WriteLine strNewTextO
objFileO.Close
' ----------------------------------------------P----------------------------------------
Const ForReadingP = 1
Const ForWritingP = 2
Set objFSOP = CreateObject("Scripting.FileSystemObject" )
Set objFileP = objFSOP.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForReadingP)
strTextP = objFileP.ReadAll
objFileP.Close
strNewTextP = Replace(strTextP, "p", mot16)
Set objFileP = objFSOP.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForWritingP)
objFileP.WriteLine strNewTextP
objFileP.Close
' ----------------------------------------------Q----------------------------------------
Const ForReadingQ = 1
Const ForWritingQ = 2
Set objFSOQ = CreateObject("Scripting.FileSystemObject" )
Set objFileQ = objFSOQ.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForReadingQ)
strTextQ = objFileQ.ReadAll
objFileQ.Close
strNewTextQ = Replace(strTextQ, "q", mot17)
Set objFileQ = objFSOQ.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForWritingQ)
objFileQ.WriteLine strNewTextQ
objFileQ.Close
' ----------------------------------------------R----------------------------------------
Const ForReadingR = 1
Const ForWritingR = 2
Set objFSOR = CreateObject("Scripting.FileSystemObject" )
Set objFileR = objFSOR.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForReadingR)
strTextR = objFileR.ReadAll
objFileR.Close
strNewTextR = Replace(strTextR, "r", mot18)
Set objFileR = objFSOR.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForWritingR)
objFileR.WriteLine strNewTextR
objFileR.Close
' ----------------------------------------------S----------------------------------------
Const ForReadingS = 1
Const ForWritingS = 2
Set objFSOS = CreateObject("Scripting.FileSystemObject" )
Set objFileS = objFSOS.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForReadingS)
strTextS = objFileS.ReadAll
objFileS.Close
strNewTextS = Replace(strTextS, "s", mot19)
Set objFileS = objFSOS.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForWritingS)
objFileS.WriteLine strNewTextS
objFileS.Close
' ----------------------------------------------T----------------------------------------
Const ForReadingT = 1
Const ForWritingT = 2
Set objFSOT = CreateObject("Scripting.FileSystemObject" )
Set objFileT = objFSOT.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForReadingT)
strTextT = objFileT.ReadAll
objFileT.Close
strNewTextT = Replace(strTextT, "t", mot20)
Set objFileT = objFSOT.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForWritingT)
objFileT.WriteLine strNewTextT
objFileT.Close
' ---------------------------------------------------------------------------------------
' PAUSE POUR LE PROGRAMME
MsgBox "75% éffectué"
' ----------------------------------------------U----------------------------------------
Const ForReadingU = 1
Const ForWritingU = 2
Set objFSOU = CreateObject("Scripting.FileSystemObject" )
Set objFileU = objFSOU.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForReadingU)
strTextU = objFileU.ReadAll
objFileU.Close
strNewTextU = Replace(strTextD, "u", mot21)
Set objFileU = objFSOU.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForWritingU)
objFileU.WriteLine strNewTextU
objFileU.Close
' ----------------------------------------------V----------------------------------------
Const ForReadingV = 1
Const ForWritingV = 2
Set objFSOV = CreateObject("Scripting.FileSystemObject" )
Set objFileV = objFSOV.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForReadingV)
strTextV = objFileV.ReadAll
objFileV.Close
strNewTextV = Replace(strTextV, "v", mot22)
Set objFileV = objFSOV.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForWritingV)
objFileV.WriteLine strNewTextV
objFileV.Close
' ----------------------------------------------W----------------------------------------
Const ForReadingW = 1
Const ForWritingW = 2
Set objFSOW = CreateObject("Scripting.FileSystemObject" )
Set objFileW = objFSOW.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForReadingW)
strTextW = objFileW.ReadAll
objFileW.Close
strNewTextW = Replace(strTextW, "w", mot23)
Set objFileW = objFSOW.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForWritingW)
objFileW.WriteLine strNewTextW
objFileW.Close
' ----------------------------------------------X----------------------------------------
Const ForReadingX = 1
Const ForWritingX = 2
Set objFSOX = CreateObject("Scripting.FileSystemObject" )
Set objFileX = objFSOX.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForReadingX)
strTextX = objFileX.ReadAll
objFileX.Close
strNewTextX = Replace(strTextX, "x", mot24)
Set objFileX = objFSOX.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForWritingX)
objFileX.WriteLine strNewTextX
objFileX.Close
' ----------------------------------------------Y----------------------------------------
Const ForReadingY = 1
Const ForWritingY = 2
Set objFSOY = CreateObject("Scripting.FileSystemObject" )
Set objFileY = objFSOY.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForReadingY)
strTextY = objFileY.ReadAll
objFileY.Close
strNewTextY = Replace(strTextY, "y", mot25)
Set objFileY = objFSOY.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForWritingY)
objFileY.WriteLine strNewTextY
objFileY.Close
' ----------------------------------------------Z----------------------------------------
Const ForReadingZ = 1
Const ForWritingZ = 2
Set objFSOZ = CreateObject("Scripting.FileSystemObject" )
Set objFileZ = objFSOZ.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForReadingZ)
strTextZ = objFileZ.ReadAll
objFileZ.Close
strNewTextZ = Replace(strTextZ, "z", mot26)
Set objFileZ = objFSOZ.OpenTextFile("C:\Users\whitedaymond\Documents\Criptage\A cripter.txt", ForWritingZ)
objFileZ.WriteLine strNewTextZ
objFileZ.Close
MsgBox "terminer"
Il crypte ce fichier qui contient sa ( c'est un exemple ) :
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
après le cryptage cela donne sa :
a
497302
289990
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
275182
1071112
831716
502238
708316
Je pense que vous avez devinez mon problème... Cela ne chiffre qu'une lettre sur deux ( la clé de cryptage utilisée ici est 1234 ).
Je pense que le programme est trop "busy" et saute des étapes pour finir les premières actions. Si vous avez une solution n'éhistez pas car je suis vraiment bloquer. ( j'ai essayer de mettre un pause de 30 sec entres chaques lettres ou une MsgBox mais sa marche pas....
Help Merci d'avance,
thomas
|
Je me suis permis de remanier ton code:
Voici ce qui en resulte.
Sub Macro1()
cript = InputBox("Entrer votre clé de criptage. Elle doit être différante de zéro." )
mot1 = 110 * cript
mot2 = 403 * cript
mot3 = 235 * cript
mot4 = 765 * cript
mot5 = 456 * cript
mot6 = 534 * cript
mot7 = 436 * cript
mot8 = 438 * cript
mot9 = 997 * cript
mot10 = 208 * cript
mot11 = 174 * cript
mot12 = 578 * cript
mot13 = 352 * cript
mot14 = 547 * cript
mot15 = 848 * cript
mot16 = 845 * cript
mot17 = 868 * cript
mot18 = 777 * cript
mot19 = 767 * cript
mot20 = 222 * cript
mot21 = 223 * cript
mot22 = 868 * cript
mot23 = 674 * cript
mot24 = 407 * cript
mot25 = 574 * cript
mot26 = 907 * cript
'_____________________________________________________________________________________________________
Const ForReadingR = 1
Const ForWritingW = 2
Const s_PathofFile = "C:\Users\whitedaymond\Documents\Criptage\A cripter.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject" )
Set objFile = objFSO.OpenTextFile(s_PathofFile, ForReadingR)
strNewText = objFile.ReadAll
objFile.Close
strTextglob = strNewText
a_strText = Split(strTextglob, " " )
For int_split = 0 To (UBound(a_strText) - 1)
If Trim(CStr(a_strText(int_split))) = "a" Then
s_letter = Trim(CStr(a_strText(int_split)))
Else
s_letter = Right(CStr(a_strText(int_split)), 1)
End If
Select Case s_letter
Case "a"
strNewText = Replace(strNewText, "a", mot1)
Case "b"
strNewText = Replace(strNewText, "b", mot2)
Case "c"
strNewText = Replace(strNewText, "c", mot3)
Case "d"
strNewText = Replace(strNewText, "d", mot4)
Case "e"
strNewText = Replace(strNewText, "e", mot5)
Case "f"
strNewText = Replace(strNewText, "f", mot6)
Case "g"
strNewText = Replace(strNewText, "g", mot7)
Case "h"
strNewText = Replace(strNewText, "h", mot8)
Case "i"
strNewText = Replace(strNewText, "i", mot9)
Case "j"
strNewText = Replace(strNewText, "j", mot10)
Case "k"
strNewText = Replace(strNewText, "k", mot11)
Case "l"
strNewText = Replace(strNewText, "l", mot12)
Case "m"
strNewText = Replace(strNewText, "m", mot13)
Case "n"
strNewText = Replace(strNewText, "n", mot14)
Case "o"
strNewText = Replace(strNewText, "o", mot15)
Case "p"
strNewText = Replace(strNewText, "p", mot16)
Case "q"
strNewText = Replace(strNewText, "q", mot17)
Case "r"
strNewText = Replace(strNewText, "r", mot18)
Case "s"
strNewText = Replace(strNewText, "s", mot19)
Case "t"
strNewText = Replace(strNewText, "t", mot20)
Case "u"
strNewText = Replace(strNewText, "u", mot21)
Case "v"
strNewText = Replace(strNewText, "v", mot22)
Case "w"
strNewText = Replace(strNewText, "w", mot23)
Case "x"
strNewText = Replace(strNewText, "x", mot24)
Case "y"
strNewText = Replace(strNewText, "y", mot25)
Case "z"
strNewText = Replace(strNewText, "z", mot26)
End Select
Set objFile = objFSO.OpenTextFile(s_PathofFile, ForWritingW)
objFile.WriteLine strNewText
objFile.Close
Next
MsgBox "Termine"
End Sub
__________________________________________________________________________
Par contre ton principe de crypter uniquement des lettres uniques sur chaque ligne je vois pas trop l interet...
|