Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- note
- description: "Summary description for {CIPHER}."
- author: ""
- date: "$Date$"
- revision: "$Revision$"
- class
- CIPHER
- feature
- arr: ARRAY2[CHARACTER]
- k_str(k, tx: STRING): STRING
- local
- i: INTEGER
- j: INTEGER
- new_k: STRING
- do
- from
- i := 1
- j := 0
- new_k := ""
- until
- i = tx.count+1
- loop
- if(tx.item (i).code > 64 and tx.item (i).code < 91) then
- new_k.append_character (k.item (j \\ k.count + 1))
- j := j + 1
- else
- new_k.append_character (tx.item (i))
- end
- i := i + 1
- end
- Result := new_k
- end
- decrypt(k, tx: STRING): STRING
- local
- i: INTEGER
- new_str: STRING
- do
- from
- i := 1
- new_str := ""
- until
- i = tx.count+1
- loop
- if(tx.item (i).code > 64 and tx.item (i).code < 91 and k.item (i).code > 64 and k.item (i).code < 91) then
- new_str.append_character((((tx.item (i).code + k.item (i).code - (65*2))\\26) + 65).to_character)
- else
- new_str.append_character (tx.item (i))
- end
- i := i + 1
- end
- Result := new_str
- end
- box(str: STRING): STRING
- local
- exp: BOOLEAN
- i: INTEGER
- j: INTEGER
- k: INTEGER
- z: INTEGER
- str1: STRING
- x: INTEGER
- times: INTEGER
- q: INTEGER
- do
- str1 := ""
- x := 0
- times := 1
- from
- i := 1
- exp := true
- until
- exp = false
- loop
- if(i*i <= str.count) then
- i := i + 1
- else
- exp := false
- end
- end
- create arr.make_filled ('*', i, i)
- from
- j := 1
- z := 1
- until
- j > i
- loop
- from
- k := 1
- until
- k > i
- loop
- if((z > str.count) = false) then
- arr.put (str.item (z), j, k)
- end
- k := k + 1
- z := z + 1
- end
- j := j + 1
- end
- from k:=1
- until k>i
- loop
- from j:=1
- until j>i
- loop
- print (arr.item (k, j)) print (" ")
- j:=j+1
- end
- k:=k+1
- print("%N")
- end
- from k:=i
- until k<I//2
- loop
- str1.append_string (getRightColumn(k,i-k+1,i))
- str1.append_string (getBottomRow(k,i-k+2,i))
- str1.append_string (getLeftColumn(k,i-k+2,i))
- str1.append_string (getTopRow(k,i-k+2,i))
- k:=k-1
- end
- Result := str1
- end
- getRightColumn(startind, endind, maxind: INTEGER):STRING
- local
- strres: STRING
- j: INTEGER
- do
- strres:=""
- from j:=startind
- until j<endind
- loop
- if (arr.item(maxind-j+1, startind)/~'*') then
- strres.append_character(arr.item (maxind-j+1, startind))
- end
- j:=j-1
- end
- RESULT:= strres
- end
- getBottomRow(startind, endind, maxind: INTEGER):STRING
- local
- strres: STRING
- j: INTEGER
- do
- strres:=""
- from j:=startind
- until j<endind
- loop
- if (arr.item(startind, j)/~'*') then
- strres.append_character(arr.item (startind, j))
- end
- j:=j-1
- end
- RESULT:= strres
- end
- getLeftColumn(startind, endind, maxind: INTEGER):STRING
- local
- strres: STRING
- j: INTEGER
- do
- strres:=""
- from j:=startind
- until j<endind
- loop
- if (arr.item(j , maxind-startind+1)/~'*') then
- strres.append_character(arr.item (j, maxind-startind+1))
- end
- j:=j-1
- end
- RESULT:= strres
- end
- getTopRow(startind, endind, maxind: INTEGER):STRING
- local
- strres: STRING
- j: INTEGER
- do
- strres:=""
- from j:=startind
- until j<endind
- loop
- if (arr.item(maxind-startind+1, maxind-j+1)/~'*') then
- strres.append_character(arr.item (maxind-startind+1, maxind-j+1))
- end
- j:=j-1
- end
- RESULT:= strres
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement