상속: ISoapXsd
예제 #1
0
        internal static byte[] FromBinHexString(string value)
        {
            char[] array  = value.ToCharArray();
            byte[] array2 = new byte[array.Length / 2 + array.Length % 2];
            int    num    = array.Length;

            if (num % 2 != 0)
            {
                throw SoapHexBinary.CreateInvalidValueException(value);
            }
            int num2 = 0;

            for (int i = 0; i < num - 1; i += 2)
            {
                array2[num2] = SoapHexBinary.FromHex(array[i], value);
                byte[] array3 = array2;
                int    num3   = num2;
                array3[num3] = (byte)(array3[num3] << 4);
                byte[] array4 = array2;
                int    num4   = num2;
                array4[num4] += SoapHexBinary.FromHex(array[i + 1], value);
                num2++;
            }
            return(array2);
        }
예제 #2
0
		[Test] // ctor (Byte [])
		public void Constructor2 ()
		{
			byte [] bytes;
			SoapHexBinary shb;
			
			bytes = new byte [] { 2, 3, 5, 7, 11 };
			shb = new SoapHexBinary (bytes);
			Assert.AreEqual ("hexBinary", shb.GetXsdType (), "#A1");
			Assert.AreEqual ("020305070B", shb.ToString (), "#A2");
			Assert.AreSame (bytes, shb.Value, "#A3");

			bytes = new byte [0];
			shb = new SoapHexBinary (bytes);
			Assert.AreEqual ("hexBinary", shb.GetXsdType (), "#B1");
			Assert.AreEqual ("", shb.ToString (), "#B2");
			Assert.AreSame (bytes, shb.Value, "#B3");

			bytes = null;
			shb = new SoapHexBinary (bytes);
			Assert.AreEqual ("hexBinary", shb.GetXsdType (), "#C1");
			try {
				shb.ToString ();
				Assert.Fail ("#C2");
			} catch (NullReferenceException) {
			}
			Assert.IsNull (shb.Value, "#C3");
		}
예제 #3
0
 static void Main(string[] args)
 {
     X509Certificate2 cert = new X509Certificate2(args[0]);
     SHA256 sha = new SHA256CryptoServiceProvider();
     byte[] result = sha.ComputeHash(cert.GetPublicKey());
     SoapHexBinary shb = new SoapHexBinary(result);
     Console.WriteLine(shb.ToString());
 }
예제 #4
0
		[Test] // ctor ()
		public void Constructor1 ()
		{
			SoapHexBinary shb = new SoapHexBinary ();
			Assert.AreEqual ("hexBinary", shb.GetXsdType (), "#1");
			try {
				shb.ToString ();
				Assert.Fail ("#2");
			} catch (NullReferenceException) {
			}
			Assert.IsNull (shb.Value, "#3");
		}
예제 #5
0
파일: Lector.cs 프로젝트: pigovsky/T3
 public virtual void SetPhotoData(string data)
 {
     if (!Directory.Exists(img))
         Directory.CreateDirectory(img);
     var binData = Convert.FromBase64String(data);
     string filename =
         new SoapHexBinary(sha1.ComputeHash(binData)) + ".jpg";
     var fd = File.OpenWrite(img  + filename);
     fd.Write(binData, 0, binData.Length);
     fd.Close();
     Photo = filename;
 }
예제 #6
0
파일: Util.cs 프로젝트: jango2015/Ironclad
 public static string hashFilesystemPath(string filesystemPath)
 {
     ////Logger.WriteLine("Hashing " + filesystemPath);
     using (FileStream stream = File.OpenRead(filesystemPath))
     {
         SHA256 sha = new SHA256Managed();
         byte[] rawHash = sha.ComputeHash(stream);
         string rc = new SoapHexBinary(rawHash).ToString();
         ////Logger.WriteLine("fresh hash of " + obj.getFilesystemPath() + " yields " + rc);
         return rc;
     }
 }
예제 #7
0
        private static byte FromHex(char hexDigit, string value)
        {
            byte result;

            try
            {
                result = byte.Parse(hexDigit.ToString(), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
            }
            catch (FormatException)
            {
                throw SoapHexBinary.CreateInvalidValueException(value);
            }
            return(result);
        }
예제 #8
0
 // Token: 0x0600565A RID: 22106 RVA: 0x0013139C File Offset: 0x0012F59C
 private static byte[] ToByteArray(string value)
 {
     char[] array = value.ToCharArray();
     if (array.Length % 2 != 0)
     {
         throw new RemotingException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_SOAPInteropxsdInvalid"), "xsd:hexBinary", value));
     }
     byte[] array2 = new byte[array.Length / 2];
     for (int i = 0; i < array.Length / 2; i++)
     {
         array2[i] = SoapHexBinary.ToByte(array[i * 2], value) * 16 + SoapHexBinary.ToByte(array[i * 2 + 1], value);
     }
     return(array2);
 }
예제 #9
0
 private static byte[] ToByteArray(string value)
 {
     char[] charArray = value.ToCharArray();
     if (charArray.Length % 2 != 0)
     {
         throw new RemotingException(string.Format((IFormatProvider)CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_SOAPInteropxsdInvalid"), (object)"xsd:hexBinary", (object)value));
     }
     byte[] numArray = new byte[charArray.Length / 2];
     for (int index = 0; index < charArray.Length / 2; ++index)
     {
         numArray[index] = (byte)((uint)SoapHexBinary.ToByte(charArray[index * 2], value) * 16U + (uint)SoapHexBinary.ToByte(charArray[index * 2 + 1], value));
     }
     return(numArray);
 }
 public static string getMD5HashOfFile(string path)
 {
     try
     {
         if (string.IsNullOrEmpty(path))
             throw new Exception("No args provided");
         if (!File.Exists(path))
             throw new Exception("File " + path + " doesn't exist.");
         Stream inputStream = File.OpenRead(path);
         HashAlgorithm algorithm = MD5.Create();
         byte[] hash = algorithm.ComputeHash(inputStream);
         SoapHexBinary output = new SoapHexBinary(hash);
         return output.ToString();
     }
     catch (Exception e)
     {
         sendError("MD5 Error --- " + e.Message.ToString());
         return "";
     }
 }
예제 #11
0
파일: Progresivo.cs 프로젝트: ayeec/evote
 void saveOrCreateFile()
 {
     string error = "";
     SoapHexBinary soap = new SoapHexBinary(encriptarint(0));
     string enc = soap.ToString();
     for (int i = 0; i < list.Count; i++)
     {
         string puesto = list.Item(i).Attributes.GetNamedItem("puesto").Value;
         XmlNodeList tmp = list.Item(i).ChildNodes;
         for (int j = 0; j < tmp.Count; j++)
         {
             string candidato = tmp.Item(j).Attributes.GetNamedItem("nombre").Value;
             string partido = tmp.Item(j).Attributes.GetNamedItem("partido").Value;
             string insert = "insert into candidato values(null,'" + candidato + "','" + partido + "','" + puesto + "','" + enc +"');";
             if (Sqlite3.sqlite3_exec(Program.db, insert, null, null, ref error) != Sqlite3.SQLITE_OK)
             {
                 MessageBox.Show(error);
             }
         }
     }
 }
예제 #12
0
 public void DisplayMsg()
 {
     DisplayMTI();
     ISO8583FieldsUpdater Updater = new ISO8583FieldsUpdater();
     Updater.ClearAll();
     foreach (object ElementID in (object[])m_Msg.ElementsIDs)
     {
         object Val = m_Msg.get_ElementValue((int)ElementID);
         if (Val is string)
             Updater.InsertField((int)ElementID, (string)Val, false);
         else
         {
             SoapHexBinary H = new SoapHexBinary((byte[])Val);
             Updater.InsertField((int)ElementID, H.ToString(), true);
         }
     }
     DataBind();
     object	ISOBuf	=	null;
     TValidationError Error = m_Msg.ToISO(out ISOBuf);
     if (Error == TValidationError.NoError)
     {
         SoapHexBinary H = new SoapHexBinary((byte[])ISOBuf);
         MessageHexDump.Text = H.ToString();
         ISO8583XML.Text = Server.HtmlEncode(m_Msg.XML).Replace("\n", "<br/>").Replace("\t", "&nbsp;&nbsp;");
     }
     DisplayError(Error);
 }
예제 #13
0
        //public static int ToEpoch(this DateTime dateTime)
        //{
        //    var t = (dateTime.ToUniversalTime() - new DateTime(1970, 1, 1));
        //    return (int)t.TotalSeconds;
        //}

        public static string ToHex(this byte[] data)
        {
            var shb = new SoapHexBinary(data);
            return shb.ToString();
        }
예제 #14
0
 ///<summary>
 ///
 /// Metodo para converter string em uma string hexadecimal
 /// 
 ///</summary>
 public static string convertToHexa(string hexa)
 {
     byte[] toBytes = Encoding.ASCII.GetBytes(hexa);
     SoapHexBinary shb = new SoapHexBinary(toBytes);
     return shb.ToString();
 }
예제 #15
0
		public void Value ()
		{
			byte [] bytes;
			SoapHexBinary shb = new SoapHexBinary ();

			bytes = new byte [] { 2, 3, 5, 7, 11 };
			shb.Value = bytes;
			Assert.AreSame (bytes, shb.Value, "#1");

			bytes = null;
			shb.Value = bytes;
			Assert.IsNull (shb.Value, "#2");

			bytes = new byte [0];
			shb.Value = bytes;
			Assert.AreSame (bytes, shb.Value, "#3");
		}
예제 #16
0
 public static string ByteArrayToHexString(byte[] bytes)
 {
     var shb = new SoapHexBinary(bytes);
     return shb.ToString();
 }
        public static string ArchetypeDigest(ARCHETYPE archetype)
        {
            var settings = new XmlWriterSettings
            {
                Encoding = Encoding.UTF8,
                OmitXmlDeclaration = true,
                Indent = false
            };

            //#if DEBUG
            //            using (var writer = XmlWriter.Create(@".\CanonicalArchetype2.xml", new XmlWriterSettings { Indent = true }))
            //                AmSerializer.Serialize(writer, archetype);
            //#endif

            byte[] data;

            using (MemoryStream stream = AmSerializer.Serialize(settings, archetype))
            {
#if XMLParser
                AmSerializer.ValidateArchetype(stream);
#endif
                data = stream.ToArray();
            }

            // Remove UTF-8 BOM 
            int offset = 0;

            if (data.Length < 1)
                throw new ApplicationException("Canonical archetype model must have length greater than 0");

            if (data[0] == 239) // UTF-8 BOM: EF BB BF (239 187 191)
            {
                offset = 3;

                if (data.Length <= offset)
                    throw new ApplicationException("Canonical archetype model must have length greater than the BOM offset");
            }

            if (data[offset] != 60) // XML root element (<)
                throw new ApplicationException("Unexpected start character of canonical archetype model");

            MD5 md5 = new MD5CryptoServiceProvider();
            SoapHexBinary hexEncoder = new SoapHexBinary(md5.ComputeHash(data, offset, data.Length - offset));
            return hexEncoder.ToString();
        }
        public static void WriteBinaryExchange(XmlWriter writer, BinaryExchange binaryExchange, WSTrustConstantsAdapter trustConstants)
        {
            if (writer == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer");
            }

            if (binaryExchange == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("binaryExchange");
            }

            if (trustConstants == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("trustConstants");
            }

            string binaryData = null;
            switch (binaryExchange.EncodingType.AbsoluteUri)
            {
                case WSSecurity10Constants.EncodingTypes.Base64:
                    {
                        binaryData = Convert.ToBase64String(binaryExchange.BinaryData);
                        break;
                    }

                case WSSecurity10Constants.EncodingTypes.HexBinary:
                    {
                        SoapHexBinary hexBinary = new SoapHexBinary(binaryExchange.BinaryData);
                        binaryData = hexBinary.ToString();
                        break;
                    }

                default:
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new WSTrustSerializationException(SR.GetString(
                            SR.ID3217,
                            binaryExchange.EncodingType.AbsoluteUri,
                            string.Format(CultureInfo.InvariantCulture, "({0}, {1})", WSSecurity10Constants.EncodingTypes.Base64, WSSecurity10Constants.EncodingTypes.HexBinary))));
                    }
            }

            writer.WriteStartElement(trustConstants.Prefix, trustConstants.Elements.BinaryExchange, trustConstants.NamespaceURI);
            writer.WriteAttributeString(trustConstants.Attributes.ValueType, binaryExchange.ValueType.AbsoluteUri);
            writer.WriteAttributeString(trustConstants.Attributes.EncodingType, binaryExchange.EncodingType.AbsoluteUri);
            writer.WriteString(binaryData);
            writer.WriteEndElement();
        }
예제 #19
0
 /// <summary>Converts the specified <see cref="T:System.String" /> into a <see cref="T:System.Runtime.Remoting.Metadata.W3cXsd2001.SoapHexBinary" /> object.</summary>
 /// <returns>A <see cref="T:System.Runtime.Remoting.Metadata.W3cXsd2001.SoapHexBinary" /> object that is obtained from <paramref name="value" />.</returns>
 /// <param name="value">The String to convert. </param>
 public static SoapHexBinary Parse(string value)
 {
     byte[] value2 = SoapHexBinary.FromBinHexString(value);
     return(new SoapHexBinary(value2));
 }
예제 #20
0
 /// <summary>将指定的 <see cref="T:System.String" /> 转换为 <see cref="T:System.Runtime.Remoting.Metadata.W3cXsd2001.SoapHexBinary" /> 对象。</summary>
 /// <returns>从 <paramref name="value" /> 获取的 <see cref="T:System.Runtime.Remoting.Metadata.W3cXsd2001.SoapHexBinary" /> 对象。</returns>
 /// <param name="value">要转换的 String。</param>
 public static SoapHexBinary Parse(string value)
 {
     return(new SoapHexBinary(SoapHexBinary.ToByteArray(SoapType.FilterBin64(value))));
 }
예제 #21
0
파일: RuleSet.cs 프로젝트: GaloisInc/FiveUI
 private static string urlToFile(string url)
 {
     var data = Encoding.UTF8.GetBytes(url);
     var hash = SHA1.Create().ComputeHash(data);
     var soap = new SoapHexBinary(hash);
     return soap.ToString();
 }
예제 #22
0
파일: Main.cs 프로젝트: shuikeyi/gwtool
        private FileType AnalyzeFile(string file)
        {
            // The format is stored in the first 3-4 bytes
            byte[] buffer = new byte[3];
            string hex;

            using (FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read))
            {
                fs.Read(buffer, 0, buffer.Length);

                SoapHexBinary shb = new SoapHexBinary(buffer);
                hex = shb.ToString();
            }

            switch (hex)
            {
                case "5D0000":
                    return FileType.LZMA;

                case "474D41":
                    return FileType.GMAD;

                case "445550":
                    return FileType.DUPE;

                case "474D53":
                    return FileType.GMS;

                default:
                    return FileType.Uknown;
            }
        }
예제 #23
0
        internal override void SaveAssembly(AssemblyInformation asm, byte[] asmBytes)
        {
            string installed = (asm.Type ==AssemblyType.Core) ? "Y" : "N";
            SoapHexBinary shb = new SoapHexBinary(Compression.Compress(asmBytes));
            string asmHex = null;
            if (asmBytes != null)
                asmHex = shb.ToString();
            string sql;

            if (String.IsNullOrEmpty(asm.Code))
            {
                asm.Code = b1DAO.GetNextCode("DOVER_MODULES");
                sql = String.Format(this.GetSQL("SaveAssembly.sql"),
                        asm.Code, asm.Code, asm.Name, asm.Description, asm.FileName, asm.Version, asm.MD5, asm.Date.ToString("yyyyMMdd"), asmBytes.Length,
                        asm.TypeCode, installed, asm.Namespace);
            }
            else
            {
                sql = String.Format(this.GetSQL("UpdateAssembly.sql"), asm.Version, asm.MD5, asm.Date.ToString("yyyyMMdd"), asmBytes.Length, asm.Code,
                    asm.Description, installed);
                b1DAO.ExecuteStatement(String.Format(this.GetSQL("DeleteAssembly.sql"), asm.Code));
                b1DAO.ExecuteStatement(String.Format(this.GetSQL("DeleteDependencies.sql"), asm.Code));
            }

            b1DAO.ExecuteStatement(sql);

            // Modules binaries
            if (asmBytes != null)
                InsertAsmBin(asm, asmHex);
        }
 public static string GetString(byte[] value)
 {
     var shb = new SoapHexBinary(value);
     return "0x" + shb;
 }
예제 #25
0
        public string SaveLicense(string xml, string licenseNamespace)
        {
            if (string.IsNullOrWhiteSpace(xml))
            {
                throw new ArgumentNullException();
            }

            byte[] xmlBytes = convertToByteArray(xml);
            SoapHexBinary shb = new SoapHexBinary(Compression.Compress(xmlBytes));
            string xmlHex = null;
            xmlHex = shb.ToString();

            string code = b1DAO.ExecuteSqlForObject<string>(string.Format(this.GetSQL("GetLicenseCode.sql"), licenseNamespace));

            b1DAO.ExecuteStatement(string.Format(this.GetSQL("DeleteLicense.sql"), code));
            b1DAO.ExecuteStatement(string.Format(this.GetSQL("DeleteLicenseHeader.sql"), code));

            code = b1DAO.GetNextCode("DOVER_LICENSE");

            b1DAO.ExecuteStatement(string.Format(this.GetSQL("InsertLicenseHeader.sql"), code, licenseNamespace));
            InsertAsmBin(xmlHex, code);

            return code;
        }
예제 #26
0
 private void generatePassword_DoubleClick(object sender, EventArgs e)
 {
     TextBox tb = (TextBox)sender;
     statusBar("Generiram ključeve",10);
     if (tb == tbTajni)
     {
         using (AesCryptoServiceProvider AES = new AesCryptoServiceProvider())
         {
             AES.KeySize = 128;
             SoapHexBinary shb = new SoapHexBinary(AES.Key);
             tbTajni.Text = shb.ToString();
             spremi("tajni_kljuc.txt", tbTajni.Text);
         }
     }
     else if (tb == tbJavni || tb==tbPrivatni)
     {
         using (RSACryptoServiceProvider RSA = new RSACryptoServiceProvider(2048))
         {
             tbJavni.Text = RSA.ToXmlString(false);
             tbPrivatni.Text = RSA.ToXmlString(true);
             spremi("javni_kljuc.txt", tbJavni.Text);
             spremi("privatni_kljuc.txt", tbPrivatni.Text);
         }
     }
     statusBar("Ključevi generirani i pohranjeni", 100);
 }
예제 #27
0
        private static void reportHandler(Report report, object parameter)
        {
            Console.WriteLine ("Received report:\n----------------");

            Console.WriteLine ("  for RCB: " + report.GetRcbReference());

            if (report.HasTimestamp ())
                Console.WriteLine ("  timestamp: " + MmsValue.MsTimeToDateTimeOffset (report.GetTimestamp ()).ToString ());

            MmsValue values = report.GetDataSetValues ();

            byte[] entryId = report.GetEntryId ();

            if (entryId != null) {
                SoapHexBinary shb = new SoapHexBinary(entryId);

                Console.WriteLine ("  entryID: " + shb.ToString ());
            }

            Console.WriteLine ("  report dataset contains " + values.Size () + " elements");

            for (int i = 0; i < values.Size(); i++) {
                if (report.GetReasonForInclusion(i) != ReasonForInclusion.REASON_NOT_INCLUDED) {
                    Console.WriteLine("    element " + i + " included for reason " + report.GetReasonForInclusion(i).ToString() + " " + values.GetElement(i));
                }

                if (report.HasDataReference()) {
                    Console.WriteLine("       data-ref: " + report.GetDataReference(i));
                }

            }

            ReportControlBlock rcb = (ReportControlBlock) parameter;

            Console.WriteLine("  For RCB: " + rcb.GetObjectReference() + " Buffered: " + rcb.IsBuffered() +
                              " data-set: " + rcb.GetDataSetReference ());
        }
예제 #28
0
 public static string ByteArrayToString(byte[] ba)
 {
     SoapHexBinary Hex = new SoapHexBinary(ba);
     return Hex.ToString();
 }
예제 #29
0
파일: Progresivo.cs 프로젝트: ayeec/evote
 void executeUpdates()
 {
     for (int x = 0; x < ctrPaneles; x++)
     {
         if(!String.IsNullOrEmpty(updates[x])){
         string select = "select votos from candidato where nombre='" + updates[x] + "';";
         Sqlite3.Vdbe pstmt = new Sqlite3.Vdbe();
         Sqlite3.sqlite3_prepare_v2(Program.db, select, select.Length, ref pstmt, 0);
         Sqlite3.sqlite3_step(pstmt);
         string des=Sqlite3.sqlite3_column_text(pstmt, 0);
         int voto = desencriptarint( SoapHexBinary.Parse(des).Value);
         voto++;
         string enc = new SoapHexBinary(encriptarint(voto)).ToString();
         string update = "update candidato set votos='" + enc + "' where nombre='" + updates[x] + "';";
         string error = "";
         if (Sqlite3.sqlite3_exec(Program.db, update, null, null, ref error) != Sqlite3.SQLITE_OK)
         {
             MessageBox.Show(error);
         }
         Sqlite3.sqlite3_finalize(pstmt);
             
         }
     }
 }