Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/bitlbee_config/core_extensions/string.rb

Instance Method Summary collapse

Instance Method Details

#decrypt_bitlbee_password(key) ⇒ String

Decrypt a bitlbee account password Used to decrypt passwords for individual IM accounts with the password of the bitlbee user

Parameters:

  • key (String)

    Key to decrypt with

Returns:

  • (String)

    The cleartext version of this string



40
41
42
43
44
45
# File 'lib/bitlbee_config/core_extensions/string.rb', line 40

def decrypt_bitlbee_password(key)
  cmd = Mixlib::ShellOut.new(" bitlbee -x dec '#{ key }' '#{ self }'")
  cmd.run_command
  cmd.error!
  cmd.stdout.chomp
end

#encrypt_bitlbee_password(key) ⇒ String

Encrypt a bitlbee account password Used to encrypt passwords for individual IM accounts with the password of the bitlbee user

Parameters:

  • key (String)

    Key to encrypt with

Returns:

  • (String)

    The encrypted version of this string



28
29
30
31
32
33
# File 'lib/bitlbee_config/core_extensions/string.rb', line 28

def encrypt_bitlbee_password(key)
  cmd = Mixlib::ShellOut.new(" bitlbee -x enc '#{ key }' '#{ self }'")
  cmd.run_command
  cmd.error!
  cmd.stdout.chomp
end

#matches_bitlbee_password_hash?(hash) ⇒ Boolean

Check whether this string matches a given bitlbee password hash

Returns:

  • (Boolean)


17
18
19
20
21
# File 'lib/bitlbee_config/core_extensions/string.rb', line 17

def matches_bitlbee_password_hash?(hash)
  cmd = Mixlib::ShellOut.new(" bitlbee -x chkhash '#{ hash }' '#{ self }'")
  cmd.run_command
  cmd.exitstatus == 0
end

#to_bitlbee_password_hashString

Get the bitlbee password hash for this string

Returns:

  • (String)

    The bitlbee password hash for this string



7
8
9
10
11
12
# File 'lib/bitlbee_config/core_extensions/string.rb', line 7

def to_bitlbee_password_hash
  cmd = Mixlib::ShellOut.new(" bitlbee -x hash '#{ self }'")
  cmd.run_command
  cmd.error!
  cmd.stdout.chomp
end