Sha256: bfddd286a8c3c4d518f042027624c6a63b79b844c868e4704eb5ac089a88c47b
Contents?: true
Size: 1023 Bytes
Versions: 1
Compression:
Stored size: 1023 Bytes
Contents
# crypt.rb require 'base64' module HipChatSecrets class Crypt def self.encode str Base64::encode64(xor str).strip end def self.decode str xor Base64::decode64(str) end def self.xor input input = input.unpack 'U*' output = [] input.each_with_index do |num,index| output << (num ^ secret[index%secret.length]) end output.pack 'U*' end # You have to figure out the Secret on your own. Good luck! def self.secret return @@key if defined? @@key key_file = File.expand_path('~/.hipchat_secret') send 'secret=', if ENV['HIPCHAT_SECRET'] ENV['HIPCHAT_SECRET'] elsif File.exists? key_file File.open(key_file, 'r') {|f| f.read } else raise "Could not locate HipChat Secret Key in HIPCHAT_SECRET or #{key_file}" end end def self.secret= key @@key = key.strip.unpack 'U*' end def self.secret_str secret.pack 'U*' end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hipchat-secrets-0.9.1 | lib/crypt.rb |