Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 2b0c1ceffe
Fetching contributors…

Cannot retrieve contributors at this time

file 67 lines (59 sloc) 1.961 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
# install.rb Richard Kernahan <kernighan_rich@rubyforge.org>

require 'fileutils'

puts "Installation for Crypt :: pure-ruby cryptographic library"

print " [ ] Looking for installation directory ... "
installationFolder = $:.find {|d| d =~ /lib.ruby.site_ruby.1.8$/}
installationFolder = $:.find {|d| d =~ /lib.ruby.1.8$/} unless installationFolder
installationFolder = $:[0] unless installationFolder
if installationFolder.nil?()
  print "failed\n Sorry. Could not find a directory to install in.\n It might be easier to use the rubygem.\n"
  exit 1
end
print "ok --> #{installationFolder} \n"

print " [ ] checking that the directory is writable ... "
unless File.writable?(installationFolder)
  print "failed\n It appears you do not have sufficient authority to install Crypt \n"
  print " to the directory #{installationFolder}\n"
  exit 2
end
print "ok\n"

cryptDir = installationFolder + "/crypt"
if File.exist?(cryptDir)
  print " [ ] folder #{cryptDir} already exists.\n"
else
  print " [ ] creating folder #{cryptDir} ... "
  begin
    Dir.mkdir(cryptDir)
  rescue SystemCallError
    print "failed.\n Sorry. We were unable to create the directory.\n"
    exit 3
  end
  print "ok\n"
end

#gen filesToInstall()
filesToInstall = [
  'crypt/blowfish.rb',
  'crypt/blowfish-tables.rb',
  'crypt/cbc.rb',
  'crypt/gost.rb',
  'crypt/idea.rb',
  'crypt/noise.rb',
  'crypt/rijndael-tables.rb',
  'crypt/rijndael.rb',
  'crypt/stringxor.rb',
]
#endgen

begin
  puts " [ ] installing files:"
  filesToInstall.each { |f|
    FileUtils.install(f, cryptDir)
    puts " ok #{f}"
  }
rescue
  puts " Sorry. Encountered a problem installing the files."
  exit 4
end

puts "\nCongratulations! The installation completed successfully."
puts "To use Blowfish, just add to your code:"
puts " require 'crypt/blowfish'"
puts "or a similar statement for one of the other algorithms.\n"
Something went wrong with that request. Please try again.