Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Jawne
- def initialize (napis)
- @napis = napis
- end
- def zaszyfruj (klucz)
- res = ""
- for c in 0 .. @napis.length-1 do
- res+= klucz[ @napis[c] ]
- end
- return Zaszyfrowane.new(res)
- end
- def to_s
- return @napis
- end
- end
- class Zaszyfrowane
- def initialize (napis)
- @napis=napis
- end
- def odszyfruj(klucz)
- res = ""
- for c in 0 .. @napis.length-1 do
- res+= klucz[ @napis[c] ]
- end
- return Odszyfrowane.new(res)
- end
- def to_s
- return @napis
- end
- end
- print("zad.3\n")
- klucz1 = {
- 'a' => 'b',
- 'b' => 'c',
- 'c' => 'd'
- }
- j = Jawne.new("abc")
- puts(j.to_s)
- puts(j.zaszyfruj(klucz1))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement