Welcome Guest, you are in: Login

MUST Creative Engineering Laboratory

RSS RSS

Navigation



Technical Doc



Search the wiki
»

MUST Corp.

MUST Corp.

www.must.or.kr

 Microsoft CERTIFIED Partner Software Development, Web Development, Data Platform

 Microsoft Small Business Specialist

MCSD

Microsoft Certified IT Professional

Microsoft Certified Professional Developer

Page History: [ASP.NET] 서명(signature) 생성 샘플코드

Compare Page Revisions



« Older Revision - Back to Page History - Newer Revision »


Page Revision: 2012/05/29 22:04


.NET 서명(signature)을 생성 샘플코드

소스의 00112233445566778899aabbccddeeff 는 발급받은 32자리 키입니다.

<%@Import Namespace="System.Security.Cryptography" %>

<img src="http://mqr.kr/qr/?t=HelloWorld&amp;r=10&amp;sign=<%=CalculateSign("t=HelloWorld&r=10", "00112233445566778899aabbccddeeff")%>"/>

<script runat="server">
string CalculateSign(string text, string key)
{
	byte[] keyBytes = new byte[key.Length / 2];
	for (int i = 0; i < keyBytes.Length; i++)
		keyBytes[i] = Convert.ToByte(key.Substring(i * 2, 2), 16);
	byte[] textBytes = Encoding.ASCII.GetBytes(text);
	byte[] sign;
	using (HMACSHA256 hmac = new HMACSHA256(keyBytes))
		sign = hmac.ComputeHash(textBytes);
	return string.Join(string.Empty, sign.Select(b => b.ToString("x2")));
}
</script>

MUST Creative Engineering Laboratory

ImageImage Image Image

Image Image Image Image Image Image Image

Copyright © 2010 MUST Corp. All rights reserved. must@must.or.kr
This Program is released under the GNU General Public License v2. View the GNU General Public License v2 or visit the GNU website.