Beispiel #1
0
        /// <summary>
        /// 加密票据数据
        /// </summary>
        /// <param name="ticket">票据信息</param>
        /// <param name="oParam">加密参数</param>
        /// <returns>加密后字节</returns>
        public byte[] EncryptTicket(ILibAuthenticationTicket ticket, object oParam)
        {
            string strKeyInfo = (string)oParam;

            CspParameters cspParams = new CspParameters();

            cspParams.Flags            = CspProviderFlags.UseMachineKeyStore;
            cspParams.KeyContainerName = "TicketContainer";

            RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(cspParams);

            rsa.FromXmlString(strKeyInfo);

            byte[] dataToEncrypt = Encoding.UTF8.GetBytes(ticket.Serialize());

            return(RSAEncryptData(dataToEncrypt, rsa, false));
        }
 public static string Encrypt(ILibAuthenticationTicket ticket)
 {
     return(ticket.Serialize());
 }