Proszę o pomoc. Nie potrafię zrobić schematu blokowego do tego kodu:
module CR
def self.encrypt (x,k)
srand (k*113+7)
$result = ""
x.each_byte{|y|
$result << ((y-rand (7)) .chr.to_s)
}
return $result
end
def self.encrypt (x,k)
srand (k*113+7)
$result = ""
x.each_byte{|y|
$result << ((y+rand (7)) .chr.to_s)
}
return $result
end
end
begin
print "Podaj co chcesz zrobic\n0 - zaszyfruj\n1 - odszyfruj\n"
mode = gets.chomp!
case mode
when 0 then print "\nSzyfrowanie.\n"
when 1 then print "\nDeszyfrowanie.\n"
else
print "\nZly tryb.\n"
$stdin.gets
exit
end
print "Podaj nazwe pliku który chcesz zaszyfrowac.\n"
filename = gets.chomp!
case mode
when 0 then print "\nSzyfrowanie.\n"
when 0 then print "\nDeszyfrowanie.\n"
else
print "\nZly tryb.\n"
print "Podaj nazwe pliku który chcesz zaszyfrowac"
unless File.exist? (filename)
print "Plik nie istnieje.\n"
$stdin.gets
exit
end
print "\nPodaj nazwe docelowego pliku.\n"
destination = gets.chomp!
print "\nPodaj klucz do zakodowania\n"
key2 = gets.chomp!
key = key2.to_i
if key > 100000
key = 100000
end
file = File.open(filename, 'rb')
data = file.read
file.close
file = File.open(destination, 'wb')
case (mode.to_i)
when 0 then file.write(CR.encrypt(data, key))
when 1 then file.write(CR.decrypt(data, key))
end
file.close
print "\nZakodowano.\n"
$stdin.gets
exit
rescue => e
print "Error : #{e}\n"
$stdin.gets
exit
end