sessionid.cs

来自「一个用C#编写的能实现即时通讯的工具」· CS 代码 · 共 30 行

CS
30
字号
#if !CF
using System;
using System.Text;
using System.Collections;
using System.Security.Cryptography;

namespace agsXMPP
{
	/// <summary>
	/// Summary description for SessionId.
	/// </summary>
	public class SessionId
	{
		// Lenght of the Session ID on bytes,
		// 4 bytes equaly 8 chars
		// 16^8 possibilites for the session IDs (4.294.967.296)
		// This should be unique enough
		private static int m_lenght = 4;
	
		public static string CreateNewId()
		{			
			RandomNumberGenerator RNG = RandomNumberGenerator.Create();
			byte[] buf = new byte[m_lenght];
			RNG.GetBytes(buf);
			
			return util.Hash.HexToString(buf);
		}
	}
}
#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?