ASP 改良版MD5、SHA256多重加密类(二次及多次)(9)


Case 5 ' 两次SHA256
EncryptMode = SHA256(SHA256(p_String, E1s), E2s)
Case 6 ' 前8位 MD5 算法 后8位 SHA256 算法
EncryptMode = Left(MD5(p_String, E1s), 8) & Right(SHA256(p_String, E2s), 8)
Case 7 ' 前8位 SHA256 算法 后8位 MD5 算法
EncryptMode = Left(SHA256(p_String, E2s), 8) & Right(MD5(p_String, E1s), 8)
End Select
End Function
' ============================================
' 全站密码类通用加密函数
' ============================================
Public Function PassWordEnt(ByVal p_String)
If p_String = "" or IsNull(p_String) Then p_String = 1
' 取密码最后一个字符的AscW值与8的余数作为加密方案系数
PassWordEnt = EncryptMode(p_String, AscW(LCase(Right(p_String, 1))) Mod 8)
End Function
End Class
%>

演示:
复制代码 代码如下:

<!--#include file="cls_Encrypt.asp"-->
<%
Dim o
Set o = new Cls_Encrypt
Response.write "MD5算法:" & o.EncryptMode("admin",0) & "<br />"
Response.write "SHA256算法:" & o.EncryptMode("admin",1) & "<br />"
Response.write "先MD5后SHA256:" & o.EncryptMode("admin",2) & "<br />"
Response.write "先SHA256后MD5:" & o.EncryptMode("admin",3) & "<br />"
Response.write "两次MD5:" & o.EncryptMode("admin",4) & "<br />"
Response.write "两次SHA256:" & o.EncryptMode("admin",5) & "<br />"
Response.write "前8位MD5算法后8位SHA256算法:" & o.EncryptMode("admin",6) & "<br />"
Response.write "前8位SHA256算法后8位MD5算法:" & o.EncryptMode("admin",7) & "<br /><hr />"
Response.write "取密码最后一个字符的AscW值与8的余数作为加密方案系数:" & o.PassWordEnt("admin") & "<br /><hr />"
Response.write "16位MD5加密:" & o.md5("admin",16) & "<br />"
Response.write "32位MD5加密:" & o.md5("admin",32) & "<br /><hr />"
Response.write "8位SHA256加密:" & o.sha256("admin",1) & "<br />"
Response.write "16位SHA256加密:" & o.sha256("admin",2) & "<br />"
Response.write "24位SHA256加密:" & o.sha256("admin",3) & "<br />"
Response.write "32位SHA256加密:" & o.sha256("admin",4) & "<br />"
Response.write "40位SHA256加密:" & o.sha256("admin",5) & "<br />"
Response.write "48位SHA256加密:" & o.sha256("admin",6) & "<br />"
Response.write "56位SHA256加密:" & o.sha256("admin",7) & "<br />"
Response.write "64位SHA256加密:" & o.sha256("admin",8) & "<br />"
Set o = nothing
%>