Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. REM ***** BASIC *****
  2.  
  3. sub Main
  4. kodiraj_ui()
  5.  
  6. end sub
  7. Function GesloVZrno(geslo$)
  8.  
  9. hash =0
  10. maska = &H00FFFFFF
  11.  
  12. j = LEN(geslo)
  13. If Len(geslo) > 0 Then
  14. Do While j>0
  15. znak = Mid (geslo, j, 1)
  16. A = ASC(znak)
  17. hash = 33*hash+A
  18. hash=hash AND maska
  19. j=j-1
  20. Loop
  21. End If
  22. GesloVZrno=hash AND &H00007FFF
  23.  
  24.  
  25. end Function
  26.  
  27. Function kodiraj(niz)
  28. i=1
  29. Do
  30. If Len(niz)<>0 Then
  31. znak = Mid(niz, i, 1)
  32. A = ASC(znak)
  33. if A > 31 Then
  34. rand=CInt (rnd()*31)
  35. A=A XOR rand
  36.  
  37. End if
  38.  
  39. Mid (niz, i, 1)=Chr(A)
  40.  
  41. i=i+1
  42. End If
  43. Loop Until i>Len(niz)
  44.  
  45. kodiraj=niz
  46.  
  47. end Function
  48.  
  49. sub SifrirajList(List, Zrno, Znacka$)
  50. oCell = List.GetCellbyPosition( 0, 0 ) ' Na listu izberemo celico A1
  51. oCursor = List.createCursorByRange(oCell) 'Ustvarmo navidezni kurzor, s katerim označimo območje
  52. oCursor.GotoEndOfUsedArea(True) ' ter se postavimo na konec uporabljenega območja
  53. aAddress = oCursor.RangeAddress ' zanima nas samo označeno območje
  54. stVrstic = aAddress.EndRow ' število zasedenih vrstic
  55. stStolpcev = aAddress.EndColumn ' število zasedenih stolpcev
  56. for stolpec = 0 To stStolpcev ' Na pravokotnem območju lista
  57. for vrstica = 0 To stVrstic ' preletimo vse indekse celic
  58. oCell = List.GetCellByPosition( stolpec,vrstica )
  59. vredn = oCell.Formula 'Pridobimo formulo celice - dejansko vsebino celice
  60.  
  61. vredn = SifrirajCelico(vredn, Zrno)
  62.  
  63. oCell.Formula = vredn ' In vrednost zapišemo v celico
  64. Next vrstica
  65. Next stolpec
  66.  
  67.  
  68. end sub
  69.  
  70. function kodiraj_ui()
  71.  
  72. geslo = InputBox("Vnesi geslo","Geslo","E123456789")
  73. seed = GesloVZrno(geslo)
  74. for i = 0 to ThisComponent.sheets.getCount() - 1
  75. SifrirajList(ThisComponent.sheets(i), seed)
  76. next i
  77.  
  78. end function
  79.  
  80.  
  81.  
  82. function SifrirajCelico(Celica$, Zrno, Znacka$)
  83. randomize(zrno)
  84. isFormula = 0
  85. isOriginalFormula = 0
  86. if (left(Celica, 1) = "=" or left(Celica, 1) = "-" or left(Celica, 1) = "+") then
  87. isOriginalFormula = 1
  88. end if
  89. if left(Celica, len(Znacka)) = Znacka then
  90. isFormula = 1
  91. niz = right(Celica, len(Celica)-len(Znacka))
  92. else
  93. niz = Celica
  94. end if
  95. niz = kodiraj(niz)
  96. if (left(niz, 1) = "=" or left(niz, 1) = "-" or left(niz, 1) = "+") and isFormula = 0 then
  97. SifrirajCelico = Znacka + niz
  98. elseif isOriginalFormula = 1 then
  99. SifrirajCelico = Znacka + niz
  100. else SifrirajCelico = niz
  101. end if
  102. end function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement