September 16, 2021, 12:56:18

Author Topic: [bb] RC4 Komp. Algo. by Panno [ 1+ years ago ]  (Read 630 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] RC4 Komp. Algo. by Panno [ 1+ years ago ]
« on: June 29, 2017, 00:28:38 »
Title : RC4 Komp. Algo.
Author : Panno
Posted : 1+ years ago

Description : Algorythmus

Code :
Code: BlitzBasic
  1. Dim sbox(255)
  2. Dim keyh(255)
  3. Global key$
  4. Global rc4$
  5. Global re$
  6. Global ec$
  7. Global clear$
  8. Global rc4k
  9. Global rc4cryp
  10. Key$="TEST KEY"  ; your key up to 255 bytes long
  11.  
  12.  
  13. clear$="SAFE YOUR DATA AND CODE WITH THE COOL RC4 ALGORYTMUS - (only private use, payment for commerzial) !"
  14. rc4init (key$)
  15. a$= rc4cryp$(clear$)
  16. Print a$
  17. rc4init (key$)
  18. clear$= rc4enc$(a$)
  19. Print clear$
  20. WaitKey()
  21. End
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30. Function  rc4init(key$)     ;__________________-- init sbox and keyh
  31.    keylen = Len(key$)
  32.       For i = 0 To 255
  33.          sbox(i) = i
  34.          kptr =kptr+1
  35.          keyh(i) = Asc(Mid$(key$,kptr,1))
  36.          If kptr = keylen Then kptr = 0
  37.       Next
  38.       For i = 0 To 255
  39.  
  40.          j = (j+sbox(i)+keyh(i))
  41.          j= j Mod 256
  42.          swap = sbox(i)
  43.          sbox(i) = sbox(j)
  44.          sbox(j) = swap
  45.       Next
  46.        
  47. i = rc4k(1)
  48.  
  49. End Function
  50.  
  51.  
  52.  
  53. Function rc4k(init)    ;__________________
  54. Local x,y
  55.  
  56. If initflag Then
  57.     x=0
  58.       y=0
  59.       Else
  60.  
  61.          x =x+1
  62.          x =x Mod 256
  63.          y =y+(sbox(x))
  64.          y =y Mod 256
  65.          swap =  sbox(x)
  66.          sbox(x) = sbox(y)
  67.          sbox(y) = swap
  68.          t = sbox(x)+sbox(y)
  69.          t =t Mod 256
  70.          
  71.          rc4k =sbox(t)
  72.          Return rc4k
  73.  
  74. End If
  75. End Function
  76.  
  77. Function rc4cryp$(s$) ;___________________ cryp
  78.  
  79. slen = Len(s$)
  80. For r = 1 To slen
  81. c = Asc(Mid$(s$,r,1))
  82. k = rc4k(0)
  83.  
  84. re$=re$+(Chr$(c Xor k))
  85. Next
  86. rc4$= re$
  87.  
  88. Return rc4$
  89. End Function
  90.  
  91. Function rc4enc$ (s$) ;__________________-- decryp
  92. strl= Len(s$)
  93. For x = 1 To strl
  94. c = Asc(Mid$(s$,x,1))
  95. k = rc4k(0)
  96. r$= r$+Chr$(c Xor k)
  97. Next
  98. Return r$
  99. End Function


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal