openfire 註冊使用者加密方法解析

來源:互聯網
上載者:User

      Openfire是通過org.jivesoftware.util.Blowfish.java實現的加密。

      使用Blowfish的encryptString(String
password)和decryptString(String encryptedString)兩個方法執行加解密。
      可new Blowfish(String passwordKey)需要passwordKey,上哪裡找?
      原來在openfire的資料庫中有表ofproperty,其中就有passwordKey的值,這是openfire安裝時自動產生的。

      openfire每次自動產生資料庫的時候這個屬性都是不同的,所以如果資料庫變化了,原來的使用者資訊匯入是沒有用的。

      可以獨立使用org.jivesoftware.util.Blowfish.java進行加解密操作。


      將org.jivesoftware.util.Blowfish.java拷貝到自己的項目中來,範例程式碼如下:

public String getEncryPWD(String noEncryPWD) {String resultPWD = null;String passWordKey = null; //passwordKey,從openfire資料庫中讀取/* * 下面這段是從ofProperty表中查詢得到passwordKey的值。OfProperty ofProperty = ofPropertyMapper.selectByPrimaryKey("passwordKey");if (ofProperty != null) {passWordKey = ofProperty.getPropvalue();} */Blowfish blowFish = new Blowfish(passWordKey); //根據加密key初始化passWordKey = blowFish.encryptString(noEncryPWD); //加密return resultPWD; //返回加密後的結果}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.