Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- REM ***** BASIC *****
- sub Main
- kodiraj_ui()
- end sub
- Function GesloVZrno(geslo$)
- hash =0
- maska = &H00FFFFFF
- j = LEN(geslo)
- If Len(geslo) > 0 Then
- Do While j>0
- znak = Mid (geslo, j, 1)
- A = ASC(znak)
- hash = 33*hash+A
- hash=hash AND maska
- j=j-1
- Loop
- End If
- GesloVZrno=hash AND &H00007FFF
- end Function
- Function kodiraj(niz)
- i=1
- Do
- If Len(niz)<>0 Then
- znak = Mid(niz, i, 1)
- A = ASC(znak)
- if A > 31 Then
- rand=CInt (rnd()*31)
- A=A XOR rand
- End if
- Mid (niz, i, 1)=Chr(A)
- i=i+1
- End If
- Loop Until i>Len(niz)
- kodiraj=niz
- end Function
- sub SifrirajList(List, Zrno, Znacka$)
- oCell = List.GetCellbyPosition( 0, 0 ) ' Na listu izberemo celico A1
- oCursor = List.createCursorByRange(oCell) 'Ustvarmo navidezni kurzor, s katerim označimo območje
- oCursor.GotoEndOfUsedArea(True) ' ter se postavimo na konec uporabljenega območja
- aAddress = oCursor.RangeAddress ' zanima nas samo označeno območje
- stVrstic = aAddress.EndRow ' število zasedenih vrstic
- stStolpcev = aAddress.EndColumn ' število zasedenih stolpcev
- for stolpec = 0 To stStolpcev ' Na pravokotnem območju lista
- for vrstica = 0 To stVrstic ' preletimo vse indekse celic
- oCell = List.GetCellByPosition( stolpec,vrstica )
- vredn = oCell.Formula 'Pridobimo formulo celice - dejansko vsebino celice
- vredn = SifrirajCelico(vredn, Zrno)
- oCell.Formula = vredn ' In vrednost zapišemo v celico
- Next vrstica
- Next stolpec
- end sub
- function kodiraj_ui()
- geslo = InputBox("Vnesi geslo","Geslo","E123456789")
- seed = GesloVZrno(geslo)
- for i = 0 to ThisComponent.sheets.getCount() - 1
- SifrirajList(ThisComponent.sheets(i), seed)
- next i
- end function
- function SifrirajCelico(Celica$, Zrno, Znacka$)
- randomize(zrno)
- isFormula = 0
- isOriginalFormula = 0
- if (left(Celica, 1) = "=" or left(Celica, 1) = "-" or left(Celica, 1) = "+") then
- isOriginalFormula = 1
- end if
- if left(Celica, len(Znacka)) = Znacka then
- isFormula = 1
- niz = right(Celica, len(Celica)-len(Znacka))
- else
- niz = Celica
- end if
- niz = kodiraj(niz)
- if (left(niz, 1) = "=" or left(niz, 1) = "-" or left(niz, 1) = "+") and isFormula = 0 then
- SifrirajCelico = Znacka + niz
- elseif isOriginalFormula = 1 then
- SifrirajCelico = Znacka + niz
- else SifrirajCelico = niz
- end if
- end function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement