コード例 #1
0
        public string EncryptString(string value, string keyString)
        {
            try
            {
                byte[] resultBA = new byte[value.Length], valueBA = new byte[value.Length];
                byte[] iv       = new byte[] { 0x14, 0xD7, 0x5B, 0xA2, 0x47, 0x83, 0x0F, 0xC4 };
                System.Text.ASCIIEncoding ascEncoding = new System.Text.ASCIIEncoding();
                byte[] key = new byte[24];
                ascEncoding.GetBytes(keyString, 0, keyString.Length < 24?keyString.Length:24, key, 0);

                MemoryStream memStream = new MemoryStream();
                byte[]       tempBA    = new byte[value.Length];
                ascEncoding.GetBytes(value, 0, value.Length, tempBA, 0);
                System.Security.Cryptography.CryptoStream cStream = new System.Security.Cryptography.CryptoStream(memStream, System.Security.Cryptography.TripleDESCryptoServiceProvider.Create().CreateEncryptor(key, iv), System.Security.Cryptography.CryptoStreamMode.Write);
                cStream.Write(tempBA, 0, tempBA.Length);
                cStream.FlushFinalBlock();
                resultBA = memStream.ToArray();
                cStream.Close();


                return(InternalMethods.BytesToHexString(resultBA));
            }
            catch (Exception exc)
            {
                LogEvent(exc.Source, "EncryptString()", exc.ToString(), 4);
                return("");
            }
        }
コード例 #2
0
 public string ConvertBinaryToHex(byte[] binary)
 {
     try
     {
         return(InternalMethods.BytesToHexString(binary));
     }
     catch (Exception exc)
     {
         LogInternalEvent(exc, 4);
         throw exc;
     }
 }