当前位置: 首页>>代码示例>>C#>>正文


C# System.Text.UTF8Encoding.GetString方法代码示例

本文整理汇总了C#中System.Text.UTF8Encoding.GetString方法的典型用法代码示例。如果您正苦于以下问题:C# System.Text.UTF8Encoding.GetString方法的具体用法?C# System.Text.UTF8Encoding.GetString怎么用?C# System.Text.UTF8Encoding.GetString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Text.UTF8Encoding的用法示例。


在下文中一共展示了System.Text.UTF8Encoding.GetString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: readText

 public string readText()
 {
     byte[] stringBuffer = new byte[TRANSBUFSIZE];
     System.Text.UTF8Encoding  encoding=new System.Text.UTF8Encoding();
     int bytesReceived = receive (ref stringBuffer);
     return encoding.GetString (stringBuffer, 0, bytesReceived);
 }
开发者ID:BjornNorgaard,项目名称:I4IKN,代码行数:7,代码来源:Transport.cs

示例2: ComputeHashString

 protected string ComputeHashString(string rawString)
 {
     System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
     SHA256 hashM = new SHA256Managed();
     return encoding.GetString(hashM.ComputeHash(encoding.GetBytes(rawString))).
         Replace(',', '.').Replace('\r', '.').Replace('\n', '.');
 }
开发者ID:ne-sachirou,项目名称:yUsin-1,代码行数:7,代码来源:DatasData.cs

示例3: build_page_1

        private void build_page_1()
        {
            TextView tv1 = new TextView ();

            try
            {
                string rez = "Adeptus.Resources.resources";
                string key = "mystring1";
                string resourceType = "";
                byte[] resourceData;
                ResourceReader r = new ResourceReader(rez);
                r.GetResourceData (key, out resourceType, out resourceData);
                r.Close();
                System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
                tv1.Buffer.Text = enc.GetString (resourceData);
            }
            catch (Exception exp)
            {
                tv1.Buffer.Text = exp.Message;
            }

            tv1.WrapMode = WrapMode.Word;
            tv1.Editable = false;

            this.AppendPage (tv1);
            this.SetPageTitle (tv1, "Introduction");
            this.SetPageType (tv1, AssistantPageType.Intro);
            this.SetPageComplete (tv1, true);
        }
开发者ID:sgtnasty,项目名称:battle,代码行数:29,代码来源:NewCharacterWindow.cs

示例4: Get

        //
        // GET: /Aes/
        public RODResponseMessage Get()
        {
            string Plain_Text;
            string Decrypted;
            string Encrypted_Text;
            byte[] Encrypted_Bytes;

            string TestKey = "SETHAwQFBgcICQoLDA0ODw==";

            //This class here the Rijndael is what will have most all of the methods we need to do aes encryption.
            //When this is called it will create both a key and Initialization Vector to use.
            RijndaelManaged Crypto = new RijndaelManaged();

            //This is just here to convert the Encrypted byte array to a string for viewing purposes.
            System.Text.UTF8Encoding UTF = new System.Text.UTF8Encoding();

            Crypto.Key = Convert.FromBase64String(TestKey);

            Console.WriteLine("Current Key: " + System.Text.Encoding.UTF8.GetString(Crypto.Key));
            Console.WriteLine("Please put in the text to be encrypted.");
            Plain_Text = "hi from seth";

            Encrypted_Bytes = encrypt_function(Plain_Text, Crypto.Key, Crypto.IV);
            Encrypted_Text = UTF.GetString(Encrypted_Bytes);
            Decrypted = decrypt_function(Encrypted_Bytes, Crypto.Key, Crypto.IV);

            RODResponseMessage m = new RODResponseMessage();
            m.message = Encrypted_Text;
            m.result = 1;

            return m;
        }
开发者ID:seth-hayward,项目名称:authie-web,代码行数:34,代码来源:AesController.cs

示例5: UncompressContent

        public static string UncompressContent(byte[] zippedContent)
        {
            try
            {
                MemoryStream inp = new MemoryStream(zippedContent);
                ZipInputStream zipin = new ZipInputStream(inp);
                ZipEntry entryin = zipin.GetNextEntry();
                byte[] buffout = new byte[(int)zipin.Length];
                zipin.Read(buffout, 0, (int)zipin.Length);

                MemoryStream decompress = new MemoryStream(buffout);

                System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
                
                string result = enc.GetString(decompress.ToArray());
                decompress.Dispose();
                inp.Dispose();

                return result;
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
                return null;
            }

        }
开发者ID:Chanicua,项目名称:GoogleHC,代码行数:27,代码来源:CompressionHelper.cs

示例6: TranslateBoneInformation

 public static string TranslateBoneInformation(byte[] boneData)
 {
     System.Text.UTF8Encoding AmericaStandardCodeII = new System.Text.UTF8Encoding();
     byte[] whiteBone = boneData.Clone() as byte[];
     for (int i = 0; i < whiteBone.Length; i++)
     {
         whiteBone[i] = byte.Parse((whiteBone[i] ^ 16).ToString());
     }
     return AmericaStandardCodeII.GetString(whiteBone);
 }
开发者ID:ViniciusConsultor,项目名称:ecustomsgs1,代码行数:10,代码来源:XRayController.cs

示例7: GetEmailBody

        public static string GetEmailBody(string templatePath)
        {
            System.Net.WebClient objWebClient = new System.Net.WebClient();
            byte[] aRequestedHTML = null;
            string strRequestedHTML = null;

            aRequestedHTML = objWebClient.DownloadData(templatePath);
            System.Text.UTF8Encoding objUTF8 = new System.Text.UTF8Encoding();
            strRequestedHTML = objUTF8.GetString(aRequestedHTML);

            return strRequestedHTML;
        }
开发者ID:vlopezjr,项目名称:TheExchange,代码行数:12,代码来源:Email.cs

示例8: GetMsgPriority

 public static int GetMsgPriority(BasicDeliverEventArgs eventArg)
 {
     var priority = -1;
     if (eventArg.BasicProperties.Headers != null && eventArg.BasicProperties.Headers.ContainsKey("Priority"))
     {
         //It's a byte, has to convert to char
         var enc = new System.Text.UTF8Encoding();
         string str = enc.GetString((byte[])eventArg.BasicProperties.Headers["Priority"]);
         int.TryParse(str, out priority);
     }
     return priority;
 }
开发者ID:kangkot,项目名称:Burrow.NET,代码行数:12,代码来源:PriorityMessageHandler.cs

示例9: ToString

		/// <summary>
		/// Convert byte array to string.
		/// </summary>
		/// <returns>The string.</returns>
		/// <param name="bytes">Byte array.</param>
		public static string ToString (byte[] bytes)
		{
			Support.LogDebug("Converting " + bytes.Length + " bytes to string.");
			if (bytes != null && bytes.Length > 0)
			{
				System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
				string result = enc.GetString(bytes);
				Support.LogDebug("Converted '" + result + "'");
				return result;
			}
			else
				return "";
		}
开发者ID:janstadt,项目名称:esl.sdk.net,代码行数:18,代码来源:Converter.cs

示例10: Create

 public static TocEntry Create(byte[] item)
 {
     var ret = new TocEntry();
     var enc = new System.Text.UTF8Encoding();
     
     int ix = 0;
     var namelength = BitConverter.ToInt32(item, ix);
     ix += sizeof (Int32);
     ret.Name = enc.GetString(item, ix, namelength);
     ix += namelength;
     ret.Length = BitConverter.ToUInt32(item, ix);
     ix += sizeof (uint);
     ret.Handle = BitConverter.ToUInt32(item, ix);
     return ret;
 }
开发者ID:jcwrequests,项目名称:TinyFS.Net,代码行数:15,代码来源:TocEntry.cs

示例11: DecryptString

        /// <summary>
        /// Decrypts a string.
        /// </summary>
        /// <param name="Message">The string to decrypt.</param>
        /// <param name="Passphrase">The passphrase to use.</param>
        /// <returns></returns>
        public static string DecryptString( string Message )
        {
            string encryptionPhrase = ConfigurationManager.AppSettings["EncryptionPhrase"];
            if ( String.IsNullOrWhiteSpace( encryptionPhrase ) )
                encryptionPhrase = "Rock Rocks!";

            byte[] Results;
            System.Text.UTF8Encoding UTF8 = new System.Text.UTF8Encoding();

            // Step 1. We hash the passphrase using MD5
            // We use the MD5 hash generator as the result is a 128 bit byte array
            // which is a valid length for the TripleDES encoder we use below

            MD5CryptoServiceProvider HashProvider = new MD5CryptoServiceProvider();
            byte[] TDESKey = HashProvider.ComputeHash( UTF8.GetBytes( encryptionPhrase ) );

            // Step 2. Create a new TripleDESCryptoServiceProvider object
            TripleDESCryptoServiceProvider TDESAlgorithm = new TripleDESCryptoServiceProvider();

            // Step 3. Setup the decoder
            TDESAlgorithm.Key = TDESKey;
            TDESAlgorithm.Mode = CipherMode.ECB;
            TDESAlgorithm.Padding = PaddingMode.PKCS7;

            // Step 4. Convert the input string to a byte[]
            byte[] DataToDecrypt = Convert.FromBase64String( Message );

            // Step 5. Attempt to decrypt the string
            try
            {
                ICryptoTransform Decryptor = TDESAlgorithm.CreateDecryptor();
                Results = Decryptor.TransformFinalBlock( DataToDecrypt, 0, DataToDecrypt.Length );
            }
            finally
            {
                // Clear the TripleDes and Hashprovider services of any sensitive information
                TDESAlgorithm.Clear();
                HashProvider.Clear();
            }

            // Step 6. Return the decrypted string in UTF8 format
            return UTF8.GetString( Results );
        }
开发者ID:ChuckWare,项目名称:Rock-ChMS,代码行数:49,代码来源:Encryption.cs

示例12: Main

    static void Main(string[] args)
    {
        System.Net.WebClient webClient = new System.Net.WebClient();

                const string request =
        "http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=YahooDemo&query=madonna&results=2";
                byte[] responseXML;
                try
                {
                        responseXML = webClient.DownloadData(request);
                        System.Text.UTF8Encoding objUTF8 = new
                        System.Text.UTF8Encoding();

        System.Console.WriteLine(objUTF8.GetString(responseXML));
                }
                catch (System.Exception)
                {
                        System.Console.WriteLine("Web services request failed");
                }
    }
开发者ID:fenbf,项目名称:search3D,代码行数:20,代码来源:simpleSearch.cs

示例13: GetRdp

        public async Task<IActionResult> GetRdp(string groupId, string resourceId)
        {
            ScampResource res = await _resourceRepository.GetResource(resourceId);
            if (res == null)
                return new HttpStatusCodeResult(404); // not found

            // can user preform this action
            if (!(await CanManageResource(res, ResourceAction.Undefined)))
                return new HttpStatusCodeResult(403); // request denied, invalid permission

            ScampSubscription sub = await _settingsRepository.GetSubscription(res.SubscriptionId);
            var provisioningController = new ProvisioningController(sub.AzureManagementThumbnail, sub.AzureSubscriptionID);


            //Response.ContentType = "application/x-rdp";
            Response.Headers.Add("content-disposition", new string[] { "attachment; filename =" + res.CloudServiceName + ".rdp" });

            byte[] bytes = await provisioningController.GetRdpAsync(res.Name, res.CloudServiceName);
            var encoding = new System.Text.UTF8Encoding();
            var sRes = encoding.GetString(bytes);
            return new ObjectResult(sRes) { StatusCode = 200 };
        }
开发者ID:hpatel98,项目名称:SCAMP,代码行数:22,代码来源:GroupsResourcesController.cs

示例14: ComputePasswordHash

        public static string ComputePasswordHash(string password, int salt)
        {
            if (String.IsNullOrEmpty(password))
                throw new ArgumentNullException("password", "Password string can't be null!");

            var utf8Encoder = new System.Text.UTF8Encoding();

            // Create byte arrays
            byte[] passwordBytes = utf8Encoder.GetBytes(password);
            byte[] saltBytes = {
                (byte)(salt >> 24), (byte)(salt >> 16), (byte)(salt >> 8), (byte)salt
            };

            // Combine two byte arrays
            byte[] bytes = new byte[passwordBytes.Length + saltBytes.Length];
            Array.Copy(passwordBytes, 0, bytes, 0, passwordBytes.Length);
            Array.Copy(saltBytes, 0, bytes, passwordBytes.Length, saltBytes.Length);

            // Encrypt byte array
            byte[] hash = (SHA512Managed.Create()).ComputeHash(bytes);

            return utf8Encoder.GetString(hash);
        }
开发者ID:AleksandarDev,项目名称:Eve,代码行数:23,代码来源:EncryptionHelper.cs

示例15: Descriptografar

 public static string Descriptografar(string Message)
 {
     byte[] Results;
     System.Text.UTF8Encoding UTF8 = new System.Text.UTF8Encoding();
     MD5CryptoServiceProvider HashProvider = new MD5CryptoServiceProvider();
     byte[] TDESKey = HashProvider.ComputeHash(UTF8.GetBytes(senha));
     TripleDESCryptoServiceProvider TDESAlgorithm = new TripleDESCryptoServiceProvider();
     TDESAlgorithm.Key = TDESKey;
     TDESAlgorithm.Mode = CipherMode.ECB;
     TDESAlgorithm.Padding = PaddingMode.PKCS7;
     byte[] DataToDecrypt = Convert.FromBase64String(Message);
     try
     {
         ICryptoTransform Decryptor = TDESAlgorithm.CreateDecryptor();
         Results = Decryptor.TransformFinalBlock(DataToDecrypt, 0, DataToDecrypt.Length);
     }
     finally
     {
         TDESAlgorithm.Clear();
         HashProvider.Clear();
     }
     return UTF8.GetString(Results);
 }
开发者ID:EmersonBessa,项目名称:FluxusWeb,代码行数:23,代码来源:MD5Crypt.cs


注:本文中的System.Text.UTF8Encoding.GetString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。