]> gitweb.fluxo.info Git - leap/leap_cli.git/commitdiff
generate secrets that are url compatible
authorelijah <elijah@riseup.net>
Tue, 11 Dec 2012 10:19:46 +0000 (02:19 -0800)
committerelijah <elijah@riseup.net>
Tue, 11 Dec 2012 10:19:46 +0000 (02:19 -0800)
lib/leap_cli/util/secret.rb

index 4833caaacf1e1c15f1b316d5270111b4a62a9f60..27770a7368aa10b2a47e749bc346105414482e35 100644 (file)
@@ -1,8 +1,8 @@
 #
 # A simple alphanumeric secret generator, with no ambiguous characters.
 #
-# It also includes symbols that are treated as word characters by most
-# terminals (so you can still double click to select the entire secret).
+# Only alphanumerics are allows, in order to make these passwords work
+# for REST url calls and to allow you to easily copy and past them.
 #
 # Uses OpenSSL random number generator instead of Ruby's rand function
 #
@@ -13,9 +13,9 @@ module LeapCli; module Util
 
   class Secret
 
-    CHARS = ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a + "_-&@%~=+".split(//u) - "io01lO".split(//u)
+    CHARS = ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a + "_".split(//u) - "io01lO".split(//u)
 
-    def self.generate(length = 10)
+    def self.generate(length = 16)
       seed
       OpenSSL::Random.random_bytes(length).bytes.to_a.collect { |byte|
         CHARS[ byte % CHARS.length ]