Class: TrueCrypt

Inherits:
Object
  • Object
show all
Defined in:
lib/truecrypt.rb

Class Method Summary collapse

Class Method Details

.close(p = {}) ⇒ Object



40
41
42
43
# File 'lib/truecrypt.rb', line 40

def self.close(p={})
  file_name = p[:file_name] || raise("You must provide the name of the volume you wish to close")
  `truecrypt -d #{file_name}`
end

.create_volume(p = {}) ⇒ Object



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
# File 'lib/truecrypt.rb', line 3

def self.create_volume(p={})

  volume_name   = p[:file_name]
  mount_point   = p[:short_name]
  volume_type   = p[:volume_type]   || 'normal'
  size          = p[:size_in_bytes] || 5_000_000  # 5Mb
  encryption    = p[:encryption]    || 'AES'
  hash          = p[:hash]          || 'Whirlpool'
  keyfiles      = p[:keyfiles]      || '""'
  random_source = p[:random_source] || __FILE__
  password      = p[:password]      || raise("Please provide a password")
  filesystem    = p[:filesystem]    || 'FAT'

  command = <<-TC
    truecrypt --text                   \
      --create #{volume_name}          \
      --volume-type=#{volume_type}     \
      --size=#{size}                   \
      --encryption=#{encryption}       \
      --hash=#{hash}                   \
      --filesystem=#{filesystem}       \
      --password=#{password}           \
      --keyfiles=#{keyfiles}           \
      --random-source=#{random_source}
  TC

  `#{command}`
end

.installed?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/truecrypt.rb', line 45

def self.installed?
  !! `which truecrypt`.chomp.match(/truecrypt$/i)
end

.open(p = {}) ⇒ Object

if no password provided, gui window will pop up



33
34
35
36
37
38
# File 'lib/truecrypt.rb', line 33

def self.open(p={})
  file_name = p[:file_name] || raise("You must provide the name of the volume you wish to open")
  short_name = p[:short_name]
  pwd_param = p[:password] && "--password=#{p[:password]}"
  `truecrypt #{file_name} #{pwd_param} #{short_name}`
end