<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,15 +1,35 @@
+require 'openssl'
+require 'Base64'
+
 class Rudolph
   class Crypt
-    def initialize key
-      @key = key
+    def initialize data_path
+      @data_path = data_path
+      @private   = get_key 'id_rsa'
+      @public    = get_key 'id_rsa.pub'
     end
-    
+
     def encrypt_string message
-      message
+      Base64::encode64(@public.public_encrypt(message)).rstrip
     end
-    
+
     def decrypt_string message
-      message
+      @private.private_decrypt Base64::decode64(message)
+    end
+
+    def self.generate_keys data_path
+      rsa_path = File.join(data_path, 'rsa')
+      privkey  = File.join(rsa_path, 'id_rsa')
+      pubkey   = File.join(rsa_path, 'id_rsa.pub')
+      keypair  = OpenSSL::PKey::RSA.generate(1024)
+      Dir.mkdir(rsa_path) unless File.exist?(rsa_path)
+      File.open(privkey, 'w') { |f| f.write keypair.to_pem } unless File.exists? privkey
+      File.open(pubkey, 'w') { |f| f.write keypair.public_key.to_pem } unless File.exists? pubkey
+    end
+
+    private
+    def get_key filename
+      OpenSSL::PKey::RSA.new File.read(File.join(@data_path, 'rsa', filename))
     end
   end
 end
\ No newline at end of file</diff>
      <filename>src/rudolph/crypt.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,18 +1,19 @@
-require 'sqlite3'
+require 'yaml'
 
 class Rudolph
   class Datastore    
     def initialize
-      @db = SQLite3::Database.new File.join(data_path, &quot;data.db&quot;)
+      @path = File.join(data_path, &quot;data.yml&quot;)
     end
     
     def get_credentials
-      @db.execute(&quot;select user, password from #{Rudolph::SQL_TABLE}&quot;).first.map { |u,p| [u,cipher.decrypt_string(p)]}
+      YAML::load_file(@path).tap { |a| a[1] = cipher.decrypt_string a[1] }
     end
     
-    def insert username, password, first_time
-      @db.execute &quot;create table #{Rudolph::SQL_TABLE}(user varchar(256), password varchar(256))&quot; if first_time
-      @db.execute &quot;insert into rudolph(user, password) values (?, ?)&quot;, username, cipher.encrypt_string(password)
+    def store_credentials username, password, first_time
+      Rudolph::Crypt.generate_keys(data_path) if first_time
+      puts &quot;#{cipher.encrypt_string(password)}******#{password}&quot;
+      File.open(@path, 'w') { |f| YAML::dump([username, cipher.encrypt_string(password)], f) }
     end
 
     def data_path
@@ -22,7 +23,7 @@ class Rudolph
     end
 
     def cipher
-      @cipher||=Rudolph::Crypt.new(Digest::SHA1.hexdigest(data_path))
+      @cipher||=Rudolph::Crypt.new data_path
     end
 
   end</diff>
      <filename>src/rudolph/datastore.rb</filename>
    </modified>
    <modified>
      <diff>@@ -17,7 +17,7 @@ Shoes.app :title =&gt; Rudolph::SYS_USR, :width =&gt; Rudolph::APP_WIDTH,
       render_update Rudolph::SYS_USR, Rudolph.message(:invalid_login_pass)
       ask_credentials first_time
     else
-      @dstore.insert @username, @password, first_time
+      @dstore.store_credentials @username, @password, first_time
     end
   end
 </diff>
      <filename>src/twitter.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>b8821fedf3e8ad0433cd844b4406666e54ea453b</id>
    </parent>
  </parents>
  <author>
    <name>Nuno Job</name>
    <email>dscape@dscape-2.local</email>
  </author>
  <url>http://github.com/dscape/rudolph/commit/c3545b22add23d42cd363cfda230b321f8a2efc1</url>
  <id>c3545b22add23d42cd363cfda230b321f8a2efc1</id>
  <committed-date>2008-12-07T21:03:16-08:00</committed-date>
  <authored-date>2008-12-07T21:03:16-08:00</authored-date>
  <message>Added RSA encryptation to prevent an even easier password theft</message>
  <tree>b088a53419930fa30a5df5be36cd8c23d062dab8</tree>
  <committer>
    <name>Nuno Job</name>
    <email>dscape@dscape-2.local</email>
  </committer>
</commit>
