Làm cách nào để tạo SHA256?

lập trình


The token is calculated as follows:
sha256(sha256(Request) + "/" + sha256(merchant + "/" + password)), where:

sha256 – calculation of data hash according to the SHA-256 algorithm and hash conversion to HEX in the uppercase format
Request – list of the "key"="value" pairs sorted by key and separated by the "&" character
merchant – Internet shop ID 
password – value set in the PosSecret parameter

< Những gì tôi đã thử:

Vui lòng trợ giúp chi tiết về vấn đề này và cung cấp mẫu sha256

Giải pháp 2

Giải pháp 1

Chỉ cần sử dụng công cụ tìm kiếm yêu thích của bạn cho từ “SHA256 (ngôn ngữ bạn chọn)” và làm theo một số tài liệu và ví dụ sẽ hiển thị.

Giải pháp 3

Đây là kịch bản bạn cần:

<% ' IMPORTANT: save this file as UTF-8 BOM !!!

function sha256(ByVal input)
	Dim hAlg,hEnc,BinaryStream,enc
	set hAlg=CreateObject("System.Security.Cryptography.SHA256Managed")
	set hEnc=CreateObject("System.Text.UTF8Encoding")	
	input=hAlg.ComputeHash_2(hEnc.GetBytes_4(input))
	' --------- security check ----------
	if NOT varType(input)=8209 then
        Set BinaryStream=CreateObject("ADODB.Stream")
		with BinaryStream
			.Type=2
			.CharSet="utf-8"
			.Open
			.WriteText input
			.Position=0
			.Type=1
			.Position=0
			input=.Read
		end with	
		set BinaryStream=Nothing
	end if
	' ----------------------------------
	set enc=CreateObject("MSXML2.DomDocument").CreateElement("encode")
	enc.dataType="bin.hex"
	enc.nodeTypedValue=input
	sha256=enc.Text
	set enc=nothing
	set hEnc=nothing
	set hAlg=nothing
end function

%>

コメント

タイトルとURLをコピーしました