Shiro的MD5加密

MD5的全称是Message Digest5,就是消息摘要算法5,需要知道它是一中不可逆算法,这意味着,尽管你知道结果是100,但你也不可能知道是99+1或者是50+50。
Shiro的MD5加密可以借助于AuthenticatingRealm的credentialsMatcher属性,借助于该属性,我们可以为其创建一个内部bean,指定bean相关属性。

<bean id="myrealm" class="cn.tj212.shiroDemo.realm.MyRealm">
        <property name="credentialsMatcher">
            <bean class="org.apache.shiro.authc.credential.HashedCredentialsMatcher">
                <!-- 1.表示当前所选用的加密算法 -->
                <property name="hashAlgorithmName" value="MD5"/>
                <property name="hashIterations" value="1024"/>
            </bean>
        </property>
    </bean>

这里的myRealm是AuthenticatingRealm的子类。

猜你喜欢

转载自blog.csdn.net/ascend2015/article/details/78556863