ï»?% '###################################################################### '## ZeroASP.Encrypt.Sha256.asp '## ------------------------------------------------------------------- '## Feature : ZeroASP Class '## Author : Ayu(kinsc@139.com) '## Update Date : 2018-11-09 '## Description : ZeroASP Extend Class '## '###################################################################### Function SHA256(ByVal Str,ByVal Types) Dim UTF8,Enc,Bytes,XML,Node,Outstr 'Borrow some objects from .NET (supported from 1.1 onwards) Set UTF8 = Server.CreateObject("System.Text.UTF8Encoding") 'UTF8Encoding/UnicodeEncoding/AscIIEncoding Set Enc = Server.CreateObject("System.Security.Cryptography.SHA256Managed") 'Convert the string to a byte array and hash it Bytes = UTF8.GetBytes_4(Str) Bytes = Enc.ComputeHash_2((Bytes)) 'Convert the byte array to a hex or bsae64 string If Types = "Base64" Then Set XML = Server.CreateObject("Msxml2.DOMDocument") Set Node = XML.CreateElement("TmpNode") Node.DataType = "bin.base64" Node.NodeTypedValue = Bytes Outstr = Replace(Node.Text,Chr(10),"") Set XML = Nothing Set Node = Nothing ElseIf Types = "Hex" Then Set XML = Server.CreateObject("Msxml2.DOMDocument") Set Node = XML.CreateElement("TmpNode") Node.DataType = "bin.hex" Node.NodeTypedValue = Bytes Outstr = Replace(Node.Text,Chr(10),"") Set XML = Nothing Set Node = Nothing End If SHA256 = Outstr Set Enc = Nothing Set UTF8 = Nothing End Function %>