SPH Forum
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
Le Deal du moment : -40%
Tefal Ingenio Emotion – Batterie de cuisine 10 ...
Voir le deal
59.99 €

mk2 crypt&decrypt 14_64b

Aller en bas

mk2 crypt&decrypt 14_64b Empty Re: mk2 crypt&decrypt 14_64b

Message par Admin Sam 10 Aoû - 11:48

Code:
UseMD5Fingerprint()
start = ElapsedMilliseconds()

hazard.q=0
Dim hazard.q(1000)
For i=0 To 1000
  cmb=Random(200)
  For u=0 To cmb
    hazard(i)+ Random(65536*32768-1)
    hazard(i)* Random(65536*32768-1)
    hazard(i)* Random(65536*32768-1)
    hazard(i)* Random(65536*32768-1)
    hazard(i)* Random(65536*32768-1)
    hazard(i)+ Random(65536*32768-1)
    hazard(i)+ Random(65536*32768-1)
  Next
  ;  Debug hazard(i)
Next
q.q

;##########################################

debut:            ;##

;##########################################

;If CreateFile(0, "d:/Test_MKey2.txt")
If CreateFile(0, "f:/Test_MKey2.txt")
Else
  MessageRequester("Error","CreateFile impossible")
  End
EndIf

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; ; ; ;  ;

mdp$="Ad"

mdp.q=0
For i=1 To Len(mdp$)
  mdp+Asc(Mid(mdp$,i,1)) 
Next
Debug "variable deduite du mdp : "+mdp

mdp_sph.q=Asc(Mid(mdp$,2,1)) 
;  Debug mdp_sph
;  End

mdp2$= StringFingerprint(mdp$, #PB_Cipher_MD5)
For i=1 To Len(mdp$)+8
  mdp2$+ StringFingerprint(mdp2$+mdp$, #PB_Cipher_MD5)
Next

Debug "longueur mdp2$ : "+Len(mdp2$)
Debug mdp2$

;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; ; ; ;  ;

Dim a.b(mdp)
For i=1 To mdp
  cmb=Random(200)
  For u=0 To cmb
    a(i)+ Random(255)
    a(i)* Random(255)
    a(i)+ Random(255)
  Next
  WriteByte(0, a(i)) ;;;;;;;;;;;                                                              #########
Next
mdp_sph=a(mdp_sph)

; Debug mdp
; End

;;;;;;;;;;;;
hazard.q+1
If hazard>1000
  hazard=0
EndIf
RandomSeed(hazard(hazard)) ;                            seed
                          ;;;;;;;

a$="$"+Mid(mdp2$,3,50)
Debug "quad_hazard : "+a$
quad_hazard.q=Val(a$)
a$="$"+Mid(mdp2$,200,44)
Debug "quad_hazard : "+a$
quad_hazard.q!Val(a$)

hazard(hazard)!quad_hazard
q=hazard(hazard)
Debug q

WriteQuad(0, q) ;                                                                #########
Debug ("===")

;=========
;=========
;=========
;=========
;=========

Dim vingt.b(21)
For i=1 To 21
  vingt(i)=Random(255)
  ;  Debug vingt(i)
Next
Debug"==="
StringFP$= StringFingerprint(mdp$+Chr(vingt(21)), #PB_Cipher_MD5)
For i=1 To 20
  StringFP$+ StringFingerprint(StringFP$+Chr(vingt(i)+mdp_sph), #PB_Cipher_MD5)
Next
Debug "longueur MD5 : "+Len(StringFP$)
Debug StringFP$

;;;;;;;;;;;;;

mdPassword=Random(100)
Debug"==="
For i=1 To Len(StringFP$)
  u=Asc(Mid(StringFP$,i,1))*i
  ;Debug u
  mdPassword!u
Next
Debug "variable deduite du MD5 : "+mdPassword

;;;;
; mdp2$= StringFingerprint(mdp$, #PB_Cipher_MD5)
; For i=1 To Len(mdp$)+8
;  mdp2$+ StringFingerprint(mdp2$+mdp$, #PB_Cipher_MD5)
; Next

mdp3$= StringFingerprint(mdp$+mdPassword+mdp_sph, #PB_Cipher_MD5)
For i=1 To Len(mdp$)+20
  mdp3$+ StringFingerprint(mdp3$+mdp$+i, #PB_Cipher_MD5)
Next
Debug mdp3$

;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;

Dim cent.l(100)
u=1
For i=1 To 100
  cent(i)=Random(65536*32768-1)
  cent(i)+Asc(Mid(StringFP$,u,1))*mdPassword*mdp+Random(65536*32768-Len(mdp$))
  u+1
  If u>Len(StringFP$)
    u=Random(Len(StringFP$)/3)+1
  EndIf
  cent(i)+Asc(Mid(StringFP$,u,1))*mdPassword*mdp+Random(65536*32768-1-Len(mdp$))
  u+1
  If u>Len(StringFP$)
    u=Random(Len(StringFP$)/3)+1
  EndIf
Next
;;;;;;;;;;;;;;;;;;;;;;;;;;
len_mdp=Len(mdp$)+mdp+mdPassword
Dim len_mdp.l(len_mdp)
;Debug len_mdp
;u=1
If u>Len(StringFP$)
  u=1
EndIf
For i=1 To len_mdp
  len_mdp(i)=Random(65536*32768-1)
  u+1
  If u>Len(StringFP$)
    u=1
  EndIf
  len_mdp(i)+Asc(Mid(StringFP$,u,1))*mdPassword*mdp+Random(65536*32768-1-Len(mdp$))
  u+1
  If u>Len(StringFP$)
    u=1
  EndIf
Next


;##############################
;##############################
;##############################
;##############################


; start = ElapsedMilliseconds()
Debug ("**********")

Dim tableau.q(0)
Dim tableaub.b(8)


If ReadFile(1, "f:\test.txt") ; Si le fichier peut être lu , on continue...
  longueur_q=(Lof(1)/8)
  longueur_b=(Lof(1)-longueur_q*8)
 
  ;Debug longueur_q
 
  q=Random(65536*32768-1)
  q*Random(65536*32768-1)
  q*Random(65536*32768-1)
  q*Random(65536*32768-1)
  q*Random(65536*32768-1)
  q+Random(65536*32768-1)
  q+Random(65536*32768-1)
  q+Random(mdPassword)
  q+Random(mdp)
  q=q!cent(Random(100))
  q=q!cent(Random(100))
  q=q!cent(Random(100))
  q=q!cent(Random(100))
  q=q!longueur_q
  Debug q
  WriteQuad(0, q);                                                                      ########
 
  q=Random(65536*32768-1)
  q*Random(65536*32768-1)+vingt(Random(20)+1)
  q*Random(65536*32768-1)
  q*Random(65536*32768-1)+vingt(Random(20)+1)
  q*Random(65536*32768-1)
  q+Random(65536*32768-1)+vingt(Random(20)+1)
  q+Random(65536*32768-1)
  q+Random(mdPassword)
  q+Random(mdp)
  q=q!cent(Random(100))
  q=q!cent(Random(100))
  q=q!cent(Random(100))
  q=q!cent(Random(100))
  q=q!longueur_b
  Debug q
  WriteQuad(0, q);                                                                      ########
 
  ;;;;;;;;
 
  ReDim tableau(longueur_q)
  rd=ReadData(1, @tableau(), Lof(1))
  q.q=tableau(longueur_q)
 
  quad$=(RSet(Bin(q), 64, "0"))
  For i=1 To 8
    tableaub(i)=Val("%"+Mid(quad$,i*8-7,8))
  Next
  CloseFile(1)
Else
  MessageRequester("Information","Impossible d'ouvrir le fichier!")
  End
EndIf

Debug  longueur_q
Debug  longueur_b

;################
sph$=mdp2$+StringFP$+mdp2$+StringFP$
;################

For a=0 To longueur_q-1  ; ecriture d'un fichier de (781250 ko soit lus de 781Mo)
                        ;;;;;; 
  ici1=Random(Len(mdp2$)+Len(StringFP$))
  ici2=Random(Len(mdp3$)-10)
 
  a$="$"+Mid(sph$,ici1,16)
  quad_hazard.q=Val(a$)
  a$="$"+Mid(mdp3$,ici2,16)
  quad_hazard.q!Val(a$)
  ;;;;;;
 
  tableau(a)!quad_hazard
    q=Random(65536*32768-1)+cent(Random(100))
    q*Random(65536*32768-1)*vingt(Random(20)+1)
    q*Random(65536*32768-1)*vingt(Random(20)+1)
    q*Random(65536*32768-1)+vingt(Random(20)+1)
    q*Random(65536*32768-1)+vingt(Random(20)+1)
    q+Random(65536*32768-1)+cent(Random(100))
    q+Random(65536*32768-1)+cent(Random(100))
  tableau(a)!q
 
  WriteQuad(0, tableau(a));                                                                      ########
 
Next a


If  longueur_b>0
  For a=1 To longueur_b
    WriteByte(0,tableaub(9-a));                                                                      ########
                              ;Debug tableaub(9-a)
  Next
EndIf

;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; ; ; ;  ; 
;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; ; ; ;  ;  ajout d'octets de brouillage
;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; ; ; ;  ; 

hazard.q+1
If hazard>1000
  hazard=0
EndIf
RandomSeed(hazard(hazard)) ;                            seed

mdp=Random(1000)+100
Dim a.b(mdp)
For i=1 To mdp
  cmb=Random(200)
  For u=0 To cmb
    a(i)+ Random(255)
    a(i)* Random(255)
    a(i)+ Random(255)
  Next
  WriteByte(0, a(i)) ;;;;;;;;;;;                                                              #########
Next

;;;;;;;;;;;;

CloseFile(0)

t = ElapsedMilliseconds()-start


Beep_(2000,50)
MessageRequester("timer",Str(t))

End

Admin
Admin

Messages : 66
Date d'inscription : 04/09/2015

https://sphforum.kanak.fr

Revenir en haut Aller en bas

mk2 crypt&decrypt 14_64b Empty Re: mk2 crypt&decrypt 14_64b

Message par Admin Sam 10 Aoû - 11:48

Code:
UseMD5Fingerprint()
start = ElapsedMilliseconds()

q.q

;##########################################
;##########################################

debut:            ;##

;##########################################
;##########################################

If ReadFile(0, "f:/Test_MKey2.txt")
  ;If CreateFile(0, "e:/Test_MKey2.txt")
  ;    FileSeek(0, Lof(0))        ; jump to the end of the file (result of Lof() is used)
Else
  MessageRequester("Error","OpenFile impossible")
  End
EndIf

;;;;;;;;;;;;;

mdp$="Ad"

mdp.q=0
For i=1 To Len(mdp$)
  mdp+Asc(Mid(mdp$,i,1)) 
Next
Debug "variable deduite du mdp : "+mdp

mdp_sph.q=Asc(Mid(mdp$,2,1)) 


mdp2$= StringFingerprint(mdp$, #PB_Cipher_MD5)
For i=1 To Len(mdp$)+8
  mdp2$+ StringFingerprint(mdp2$+mdp$, #PB_Cipher_MD5)
Next

Debug "longueur mdp2$ : "+Len(mdp2$)
Debug mdp2$

;;;;;;;;;;
Dim a.b(mdp)
For i=1 To mdp
  cmb=Random(200)
  For u=0 To cmb
    a(i)+ Random(255)
    a(i)* Random(255)
    a(i)+ Random(255)
  Next
  a(i)=ReadByte(0)
Next
mdp_sph=a(mdp_sph)

; Dim a.b(mdp)
; For i=1 To mdp
;  a=ReadByte(0) ;                                    #########
; Next

seed.q=ReadQuad(0) ;                                    #########

a$="$"+Mid(mdp2$,3,50)
Debug "quad_hazard : "+a$
quad_hazard.q=Val(a$)
a$="$"+Mid(mdp2$,200,44)
Debug "quad_hazard : "+a$
quad_hazard.q!Val(a$)

seed!quad_hazard

RandomSeed(seed);                                              seed

;=========
;=========
;=========
;=========


Dim vingt.b(21)
For i=1 To 21
  vingt(i)=Random(255)
  ;  Debug vingt(i)
Next

StringFP$= StringFingerprint(mdp$+Chr(vingt(21)), #PB_Cipher_MD5)
For i=1 To 20
  StringFP$+ StringFingerprint(StringFP$+Chr(vingt(i)+mdp_sph), #PB_Cipher_MD5)
Next

Debug "longueur MD5 : "+Len(StringFP$)
Debug StringFP$


;;;;;;;;;;;;;

mdPassword=Random(100)
Debug"==="
For i=1 To Len(StringFP$)
  u=Asc(Mid(StringFP$,i,1))*i
  ;Debug u
  mdPassword!u
Next
Debug "variable deduite du MD5 : "+mdPassword

;;;;;;;;;;;;;;;;;;;;;;;
mdp3$= StringFingerprint(mdp$+mdPassword+mdp_sph, #PB_Cipher_MD5)
For i=1 To Len(mdp$)+20
  mdp3$+ StringFingerprint(mdp3$+mdp$+i, #PB_Cipher_MD5)
Next
Debug mdp3$

;;;;;;;;;;;;;;;;;;;;


Dim cent.l(100)
u=1
For i=1 To 100
  cent(i)=Random(65536*32768-1)
  cent(i)+Asc(Mid(StringFP$,u,1))*mdPassword*mdp+Random(65536*32768-Len(mdp$))
  u+1
  If u>Len(StringFP$)
    u=Random(Len(StringFP$)/3)+1
  EndIf
  cent(i)+Asc(Mid(StringFP$,u,1))*mdPassword*mdp+Random(65536*32768-1-Len(mdp$))
  u+1
  If u>Len(StringFP$)
    u=Random(Len(StringFP$)/3)+1
  EndIf
Next


;;;;;;;;;;;;;;;;;;;;;;;;;;

len_mdp=Len(mdp$)+mdp+mdPassword
Dim len_mdp.l(len_mdp)
Debug len_mdp
;u=1
If u>Len(StringFP$)
  u=1
EndIf
For i=1 To len_mdp
  len_mdp(i)=Random(65536*32768-1)
  u+1
  If u>Len(StringFP$)
    u=1
  EndIf
  len_mdp(i)+Asc(Mid(StringFP$,u,1))*mdPassword*mdp+Random(65536*32768-1-Len(mdp$))
  u+1
  If u>Len(StringFP$)
    u=1
  EndIf
  ;Debug  len_mdp(i);=Random(65536*32768-1)
Next


;##############################
;##############################
;##############################
;##############################

; start = ElapsedMilliseconds()

q=Random(65536*32768-1)
q*Random(65536*32768-1)
q*Random(65536*32768-1)
q*Random(65536*32768-1)
q*Random(65536*32768-1)
q+Random(65536*32768-1)
q+Random(65536*32768-1)
q+Random(mdPassword)
q+Random(mdp)
q=q!cent(Random(100))
q=q!cent(Random(100))
q=q!cent(Random(100))
q=q!cent(Random(100))
longueur_q=ReadQuad(0)!q
Debug longueur_q

If longueur_q*8>Lof(0) Or longueur_q*8<0
  Beep_(500,100)
  Beep_(1500,200)
  End
EndIf

;;;;;;;;;;;;;;;

q=Random(65536*32768-1)
q*Random(65536*32768-1)+vingt(Random(20)+1)
q*Random(65536*32768-1)
q*Random(65536*32768-1)+vingt(Random(20)+1)
q*Random(65536*32768-1)
q+Random(65536*32768-1)+vingt(Random(20)+1)
q+Random(65536*32768-1)
q+Random(mdPassword)
q+Random(mdp)
q=q!cent(Random(100))
q=q!cent(Random(100))
q=q!cent(Random(100))
q=q!cent(Random(100))
longueur_b=ReadQuad(0)!q
Debug longueur_b

If longueur_b>7 Or longueur_b<0
  Beep_(500,100)
  Beep_(1500,200)
  End
EndIf

;;;;;

Dim tableau.q(longueur_q)
Dim tableaub.b(8)

;################
sph$=mdp2$+StringFP$+mdp2$+StringFP$
;################

If CreateFile(1, "f:\Test_MKey2_decrypt.txt") ; Si le fichier peut être lu , on continue...
 
 
  For a=0 To longueur_q-1  ; ecriture d'un fichier de (781250 ko soit lus de 781Mo)
    q=ReadQuad(0)
   
    ici1=Random(Len(mdp2$)+Len(StringFP$))
    ici2=Random(Len(mdp3$)-10)
   
    a$="$"+Mid(sph$,ici1,16)
    quad_hazard.q=Val(a$)
    a$="$"+Mid(mdp3$,ici2,16)
    quad_hazard.q!Val(a$)
   
    ;;;;;;
   
    quad_hazard2.q=q!quad_hazard
    q=Random(65536*32768-1)+cent(Random(100))
    q*Random(65536*32768-1)*vingt(Random(20)+1)
    q*Random(65536*32768-1)*vingt(Random(20)+1)
    q*Random(65536*32768-1)+vingt(Random(20)+1)
    q*Random(65536*32768-1)+vingt(Random(20)+1)
    q+Random(65536*32768-1)+cent(Random(100))
    q+Random(65536*32768-1)+cent(Random(100))
    quad_hazard2!q
   
   
    WriteQuad(1, quad_hazard2);                                                                      ########
                              ;          WriteQuad(1, q);                                                                      ########
  Next a
 
  If  longueur_b>0
    q=ReadQuad(0)
   
    quad$=(RSet(Bin(q), 64, "0"))
    For i=1 To 8
      tableaub(i)=Val("%"+Mid(quad$,i*8-7,8))
    Next
   
   
    For a=1 To longueur_b
      b.b=ReadByte(0)
      WriteByte(1,tableaub(9-a));                                                                      ########
    Next
  EndIf
 
  CloseFile(0)
  CloseFile(1)
 
Else
  MessageRequester("Information","Impossible de créer le fichier !")
  End
EndIf


t = ElapsedMilliseconds()-start

Beep_(2000,50)
MessageRequester("timer",Str(t))

End

Admin
Admin

Messages : 66
Date d'inscription : 04/09/2015

https://sphforum.kanak.fr

Revenir en haut Aller en bas

Revenir en haut


 
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum