System.Text.UnicodeEncoding.GetBytes C# (CSharp) Method

GetBytes() private method

private GetBytes ( char chars, int charCount, byte bytes, int byteCount ) : int
chars char
charCount int
bytes byte
byteCount int
return int
        public unsafe override int GetBytes(char* chars, int charCount, byte* bytes, int byteCount)
        {
            throw null;
        }

Same methods

UnicodeEncoding::GetBytes ( char chars, int charIndex, int charCount, byte bytes, int byteIndex ) : int
UnicodeEncoding::GetBytes ( string s, int charIndex, int charCount, byte bytes, int byteIndex ) : int

Usage Example

Esempio n. 1
0
        public static string DecryptStringWith3DES(string data, string key, string iv)
        {
            UnicodeEncoding unicode = new UnicodeEncoding();
            Byte[] Bytes = Convert.FromBase64String(data);

            MemoryStream mem = new MemoryStream(100);
            TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();

            Byte[] KeyBytes = unicode.GetBytes(key);
            Byte[] tmpBytes = new Byte[16];
            Array.Copy(KeyBytes, tmpBytes, KeyBytes.Length < 16 ? KeyBytes.Length : 16);
            KeyBytes = tmpBytes;

            if(tdes.ValidKeySize(KeyBytes.Length*8))
                System.Diagnostics.Debug.WriteLine("Key size valid");
            if(TripleDESCryptoServiceProvider.IsWeakKey(KeyBytes))
                System.Diagnostics.Debug.WriteLine("Key weak");
            CryptoStream CrStream = new CryptoStream(mem, tdes.CreateDecryptor(KeyBytes, unicode.GetBytes(iv)), CryptoStreamMode.Write);

            for(int i = 0; i < Bytes.Length; i++)
                CrStream.WriteByte(Bytes[i]);

            CrStream.FlushFinalBlock();

            string result = unicode.GetString(mem.GetBuffer(), 0, (int)mem.Length);
            CrStream.Dispose();
            return result;
        }
All Usage Examples Of System.Text.UnicodeEncoding::GetBytes