以正确的形式从Keystone数据库访问用户表中的用户密码(String)

时间:2015-03-24 12:44:41

标签: java openstack keystone

import java.sql.*;
public class userRegistration {

   static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";  
   static final String DB_URL = "jdbc:mysql://localhost/keystone";
   static final String USER = "root";
   static final String PASS = "cusat123";

   public static void main(String[] args) {
   Connection conn = null;
   Statement stmt = null;
   try{

      Class.forName("com.mysql.jdbc.Driver");

      conn = DriverManager.getConnection(DB_URL,USER,PASS);

      stmt = conn.createStatement();
      String sql;
      sql = "SELECT name,id,password FROM user";
      ResultSet rs = stmt.executeQuery(sql);
      while(rs.next()){

         String first = rs.getString("name");
         String last = rs.getString("id");
         String pwd = rs.getString("password");

         if("siju".equals(first))
         {
          if("cusatse".equals(pwd))
          {
              System.out.println("login ok");
          }
         }
         System.out.print(" username: " + first);
         System.out.println(", id: " + last);
         System.out.println(", password: " + pwd);
      }

      rs.close();
      stmt.close();
      conn.close();
   }catch(SQLException se){

      se.printStackTrace();
   }catch(Exception e){

      e.printStackTrace();
   }finally{

      try{
         if(stmt!=null)
            stmt.close();
      }catch(SQLException se2){
      }
      try{
         if(conn!=null)
            conn.close();
      }catch(SQLException se){
         se.printStackTrace();
      }
   }
   System.out.println("Goodbye!");
}

}

输出

  

用户名:siju,id:0d2809092a1e41c485181b07f8ac62ae   ,密码:$ 6 $ rounds = 40000 $ JHmpeyx13IDIJdgJ $ zFGji3SJPQ4Dx3pz6BWnIXmkVvpZNmHxMfj8qN2DOQ2K6pR5Vl / UNfjo00HJwNXRgXxEhly6N6Hf6MTaMb1d21    用户名:glance,id:47bcfb1392514dc5b890bfb14186663d   ,密码:$ 6 $ rounds = 40000 $ yDvqf1kBnvcTldCH $ DGKrrqY3mavByeM8xtqF8AaXEFiViapwHLo14WnTIE4z0N.IiCJ96lIxtmqfDKqYp2lxCQkFpff63Wh8.z2du /    用户名:nova,id:5504658950fa47239fa476e895111f5a   ,密码:$ 6 $ rounds = 40000 $ YQe7qgAKC3UiLBkM $ pFd.VCf2U6PeJnx2ejPGkW04tHq63o0fb9RiUjJTztiouH.d7UhqRmwA0aVZb6j / O..XDnhV9U4MLBnbW315Z0    用户名:admin,id:6a6bae538bd749bb8f6388ec5f3c2707   ,密码:$ 6 $ rounds = 40000 $ .6.GubHpPpkZrk5J $ RtRAI3Xd9.eAWKoQCMtfVf6jNok.n6zCcqFWlV / 1x0RWjLAxd29 / Jm9OjtNUNtK8JqJPjl0.lgyuHc1ZJVYIY0    用户名:swift,id:bce9ad99e4ad44988203180080ac022a   ,密码:$ 6 $ rounds = 40000 $ OWbwnCWLbCEPSwed $ .UbZQD4WLnjzM4n2qkSMjqpP8IIXNMtKNQuW3oqNdfvUof1 / qYVGtnEcONPphmXBbJMlOZOkQqTnTrFC03UU70    用户名:demo,id:d059821f33fa498b979b7b1539f00274   ,密码:$ 6 $ rounds = 40000 $ X8MyyrjduXoeHC1F $ e6Dc2k4bUz9YnnWY / rx0ECXW95mZhAdV8EDNnY9waLmuAXfVThME7g.V2rirhCt6WkRA4yr1jQlB9D2lTT0iL1    用户名:sunil,id:e57a4c4bce984cbebf2a4f9babd42983   ,密码:$ 6 $ rounds = 40000 $ / mrUJI0OIe6TOVWx $ z4fOjo4hRk55sI2MbE / rrkqKiPrRvY9WdNMfhsitvmeIHccO8FjeqWS7dM3KUNt0giM1Cx4ayduSQcJxKlFyP /   再见!

1.问题是密码的形式不同。

2.我可以用正确的字符串形式从Keystone数据库访问密码...... ???

1 个答案:

答案 0 :(得分:1)

您无法解密密码FROM mysql,因为密码是使用md5哈希算法进行哈希处理的,这不是一种编码算法。