public static void MergeNoFF(this IRepository repository, string branch, Signature sig) { repository.Merge(repository.FindBranch(branch), sig, new MergeOptions { FastForwardStrategy = FastForwardStrategy.NoFastFoward }); }
/// <summary> /// Creates a copy of a signature. /// </summary> /// <param name="original">Original signature to copy from.</param> public Signature(Signature original) { SignerId = original.SignerId; Data = (byte[])original.Data.Clone(); ValidFrom = original.ValidFrom; ValidUntil = original.ValidUntil; }
private static void RenameMyWishListPage(Repository repo, string myWishListPath, Signature sig) { repo.Index.Unstage(myWishListPath); File.Move(myWishListPath, myWishListPath + "List"); repo.Index.Stage(myWishListPath + "List"); repo.Commit(sig, sig, "Fix MyWishList page name"); }
public Commit CommitToBranch(Repository repo, string branchName, string message, Signature author, Tree tree) { Branch branch = repo.Branches[branchName]; Commit commit = repo.ObjectDatabase.CreateCommit(author, author, message, tree, new List<Commit> { branch.Tip }, prettifyMessage: true); repo.Refs.UpdateTarget(repo.Refs[branch.CanonicalName], commit.Id); return commit; }
private static void UpdateHomePageContent(Repository repo, string homePath, Signature sig) { File.AppendAllText(homePath, "\nThis will be a bare bone user experience.\n"); repo.Index.Stage(homePath); repo.Commit(sig, sig, "Add warning to the Home page\n\nA very informational explicit message preventing the user from expecting too much."); }
/// <summary> /// Attacker change a transfer in the middle of the chain and make the chain invalid /// </summary> public static void ChengeTransfer_SouldNotAffectTransferChain() { //Arrange var goofy = new Goofy(); var changer = new Signature(256); var person1 = new Person(); var person2 = new Person(); var trans1 = goofy.CreateCoin(changer.PublicKey); var changerSgndTrans = changer.SignMessage(trans1); var transInfo = new TransferInfo(changerSgndTrans, person1.PublicKey); var changerTransfer = trans1.PayTo(transInfo); person1.AddTransfer(changerTransfer); var tran3 = person1.PayTo(person2.PublicKey); //Act changerTransfer.Hash = null; changerTransfer.Info.DestinyPk = null; //Assert try { person2.CheckTransfers(tran3); } catch { Console.WriteLine("Transfer chain is broked because someone change a another transfer in the middle."); } }
public static Signature Decode(IByteReader stream) { Signature decodedSignature = new Signature(); int Signaturesize = XdrEncoding.DecodeInt32(stream); decodedSignature.InnerValue = XdrEncoding.ReadFixOpaque(stream, (uint)Signaturesize); return decodedSignature; }
/// <summary> /// Create an accepting response. /// </summary> /// <param name="signature">Signature of CA.</param> public SignatureResponse(Guid subjectId, Signature signature) { SubjectId = subjectId; Status = SignatureResponseStatus.Accepted; Signature = signature; Reason = string.Empty; }
public bool Matches(Signature sig) { if (ComponentTypes.Intersect(sig.ComponentTypes).Count() == sig.ComponentTypes.Count()) return true; else return false; }
/// <summary> /// Loads the signature. /// </summary> /// <param name="signature">The signature.</param> public Signature(Signature signature) { if (signature == null) throw new ArgumentNullException(@"signature"); this.token = signature.token; }
private void btnCommit_Click(object sender, RibbonControlEventArgs e) { //Get Active Project var pj = Globals.ThisAddIn.Application.ActiveProject; //Get Project Filename. var projectFile = pj.FullName; //Get Directory from File Name var directory = Path.GetDirectoryName(projectFile); //Create a new Git Repository Repository.Init(directory); //Open the git repository in a using context so its automatically disposed of. using (var repo = new Repository(directory)) { // Stage the file repo.Index.Stage(projectFile); // Create the committer's signature and commit var author = new Signature("Richard", "@ARM", DateTime.Now); var committer = author; // Commit to the repository var commit = repo.Commit("Initial commit", author, committer); } }
public static void Init(this Flow gitFlow, GitFlowRepoSettings settings, Signature author) { var repo = gitFlow.Repository; //Only init if it is not initialized if (gitFlow.IsInitialized()) //TODO: Does Init do anything if already initialized? Is it sufficient to just check the ConfigValues? Should it check branch existance as well? return; if (gitFlow.IsEmptyRepository()) { Log("New Repository Detected - Creating Master Branch"); //TODO: Decide if Init should create necesarry branches too? //Create Master branch Signature committer = author; var opts = new CommitOptions {AllowEmptyCommit = true}; repo.Commit("Initial commit", author, committer, opts); //Now make Dev } SetupMasterBranch(repo, settings.Settings[GitFlowSetting.Master], author); SetupDevBranch(repo, settings.Settings[GitFlowSetting.Develop], settings.Settings[GitFlowSetting.Master], author); //TODO.. Repo has branches settings.Settings .ToList() .ForEach(item => repo.Config.Set(GetConfigKey(item.Key), item.Value, settings.ConfigurationLocation) ); Log("Init Complete"); }
public DiffieHellmanKeyExchange (TlsContext ctx) { this.protocol = ctx.NegotiatedProtocol; switch (protocol) { case TlsProtocolCode.Tls12: Signature = new SignatureTls12 (ctx.Session.ServerSignatureAlgorithm); break; case TlsProtocolCode.Tls10: Signature = new SignatureTls10 (); break; case TlsProtocolCode.Tls11: Signature = new SignatureTls11 (); break; default: throw new NotSupportedException (); } dh = new DiffieHellmanManaged (); Y = dh.CreateKeyExchange (); var dhparams = dh.ExportParameters (true); P = dhparams.P; G = dhparams.G; using (var buffer = CreateParameterBuffer (ctx.HandshakeParameters)) Signature.Create (buffer, ctx.Configuration.PrivateKey); }
public MockCommit(ObjectId id = null) { idEx = id ?? new ObjectId(Guid.NewGuid().ToString().Replace("-", "")+ "00000000"); MessageEx = ""; ParentsEx = new List<Commit> { null }; CommitterEx = new Signature("Joe", "*****@*****.**", DateTimeOffset.Now); }
/// <summary> /// Creates a direct or symbolic reference with the specified name and target /// </summary> /// <param name="refsColl">The <see cref="ReferenceCollection"/> being worked with.</param> /// <param name="name">The name of the reference to create.</param> /// <param name="canonicalRefNameOrObjectish">The target which can be either the canonical name of a reference or a revparse spec.</param> /// <param name="signature">The identity used for updating the reflog</param> /// <param name="logMessage">The optional message to log in the <see cref="ReflogCollection"/> when adding the <see cref="Reference"/></param> /// <param name="allowOverwrite">True to allow silent overwriting a potentially existing reference, false otherwise.</param> /// <returns>A new <see cref="Reference"/>.</returns> public static Reference Add(this ReferenceCollection refsColl, string name, string canonicalRefNameOrObjectish, Signature signature, string logMessage, bool allowOverwrite = false) { Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(canonicalRefNameOrObjectish, "canonicalRefNameOrObjectish"); Reference reference; RefState refState = TryResolveReference(out reference, refsColl, canonicalRefNameOrObjectish); var gitObject = refsColl.repo.Lookup(canonicalRefNameOrObjectish, GitObjectType.Any, LookUpOptions.None); if (refState == RefState.Exists) { return refsColl.Add(name, reference, signature, logMessage, allowOverwrite); } if (refState == RefState.DoesNotExistButLooksValid && gitObject == null) { using (ReferenceSafeHandle handle = Proxy.git_reference_symbolic_create(refsColl.repo.Handle, name, canonicalRefNameOrObjectish, allowOverwrite, signature.OrDefault(refsColl.repo.Config), logMessage)) { return Reference.BuildFromPtr<Reference>(handle, refsColl.repo); } } Ensure.GitObjectIsNotNull(gitObject, canonicalRefNameOrObjectish); if (logMessage == null) { logMessage = string.Format("{0}: Created from {1}", name.LooksLikeLocalBranch() ? "branch" : "reference", canonicalRefNameOrObjectish); } refsColl.EnsureHasLog(name); return refsColl.Add(name, gitObject.Id, signature, logMessage, allowOverwrite); }
public void OnAppearing() { this.List.Clear(); Task.Run(async () => { var fileList = await FileSystem.Current.LocalStorage.GetFilesAsync(); foreach (IFile file in fileList) { using (Stream stream = await file.OpenAsync(FileAccess.Read)) { var signature = new Signature { FileName = file.Name, FilePath = file.Path, FileSize = stream.Length }; Device.BeginInvokeOnMainThread(() => { if (this.List.FirstOrDefault(x => x.FileName.Equals(signature.FileName)) == null) { this.List.Add(signature); } }); } } Device.BeginInvokeOnMainThread(() => { this.NoData = !this.List.Any(); }); }); }
public static void BuildSampleWikiRepo() { var repoPath = Repository.Init(Constants.WorkingDirectory); using (var repo = new Repository(repoPath)) { string workDir = repo.Info.WorkingDirectory; string homePath = Path.Combine(workDir, "Home"); var sig = new Signature("A. U. Thor", "*****@*****.**", new DateTimeOffset(2011, 06, 16, 10, 58, 27, TimeSpan.FromHours(2))); CreateHomePage(repo, homePath, sig); Signature sig2 = Shift(sig, TimeSpan.FromMinutes(2)); UpdateHomePageContent(repo, homePath, sig2); string myWishListPath = Path.Combine(workDir, "MyWish"); Signature sig3 = Shift(sig2, TimeSpan.FromMinutes(17)); CreateMyWishListPage(repo, myWishListPath, sig3); Signature sig4 = Shift(sig3, TimeSpan.FromMinutes(31)); RenameMyWishListPage(repo, myWishListPath, sig4); } }
/// <summary> /// Locate and return the node identified by idValue /// </summary> /// <param name="signature"></param> /// <param name="idValue"></param> /// <returns>node if found - else null</returns> /// <remarks>Tries to match each object in the Object list.</remarks> private static XmlElement SelectNodeByIdFromObjects(Signature signature, string idValue) { XmlElement node = null; // enumerate the objects foreach (DataObject dataObject in signature.ObjectList) { // direct reference to Object id - supported for all reference typs if (String.CompareOrdinal(idValue, dataObject.Id) == 0) { // anticipate duplicate ID's and throw if any found if (node != null) throw new XmlException(SR.Get(SRID.DuplicateObjectId)); node = dataObject.GetXml(); } } // now search for XAdES specific references if (node == null) { // For XAdES we implement special case where the reference may // be to an internal tag with matching "Id" attribute. node = SelectSubObjectNodeForXAdES(signature, idValue); } return node; }
public void SaveFile(string fileName, string content, string username, string email) { using (var repo = new Repository(_basePath)) { File.WriteAllText(Path.Combine(repo.Info.WorkingDirectory, fileName), content); // stage the file repo.Stage(fileName); // Create the committer's signature and commit //var user = repo.Config.Get<string>("user", "name", null); //var email = repo.Config.Get<string>("user", "email", null); var author = new Signature(username, email, DateTime.Now); var committer = author; // Commit to the repo var commitMessage = string.Format("Revision: {0}", GetRevisionCount(repo, fileName)); try { var commit = repo.Commit(commitMessage, author, committer); foreach (var parent in commit.Parents) { Console.WriteLine("Id: {0}, Sha: {1}", parent.Id, parent.Sha); } } catch (EmptyCommitException) { } // I don't care if the user didn't change anything at this time } }
/// <summary> /// Initializes a new instance of the <see cref="ReflogEntry"/> class. /// </summary> /// <param name="entryHandle">a <see cref="SafeHandle"/> to the reflog entry</param> internal unsafe ReflogEntry(git_reflog_entry* entryHandle) { _from = Proxy.git_reflog_entry_id_old(entryHandle); _to = Proxy.git_reflog_entry_id_new(entryHandle); _committer = Proxy.git_reflog_entry_committer(entryHandle); message = Proxy.git_reflog_entry_message(entryHandle); }
/// <summary> /// Constructor for the <c>TextLabel</c> object. This is /// used to create a label that can convert a XML node into a /// primitive value from an XML element text value. /// </summary> /// <param name="contact"> /// this is the contact this label represents /// </param> /// <param name="label"> /// this is the annotation for the contact /// </param> public TextLabel(Contact contact, Text label) { this.detail = new Signature(contact, this); this.type = contact.Type; this.empty = label.empty(); this.contact = contact; this.label = label; }
public void CanStoreTest() { object[] obj = new object[5]; obj[0] = new object(); obj[1] = new int(); obj[2] = new float(); obj[3] = new Action(() => { }); obj[4] = new List<int>(); Type[] types1 = obj.GetTypes(); Type[] types2 = new Type[] { typeof(object), typeof(int), typeof(float), typeof(Delegate), typeof(IList<int>) }; Assert.IsTrue(types2.CanStore(types1)); Assert.IsFalse(types1.CanStore(types2)); Signature s1 = new Signature() { ParameterTypes = types1, ReturnType = typeof(Int16) }; Signature s2 = new Signature() { ParameterTypes = types2, ReturnType = typeof(object) }; Assert.IsTrue(s2.CanStore(s1)); Assert.IsFalse(s1.CanStore(s2)); types1 = new Type[0]; types2 = new Type[0]; Assert.IsTrue(types2.CanStore(types1)); Assert.IsTrue(types1.CanStore(types2)); s1 = new Signature() { ParameterTypes = types1, ReturnType = typeof(void) }; s2 = new Signature() { ParameterTypes = types2, ReturnType = typeof(void) }; Assert.IsTrue(s2.CanStore(s1)); Assert.IsTrue(s1.CanStore(s2)); }
public static void DoubleSpendAttack_SouldHaveValidTransferChain() { //Arrange var goofy = new Goofy(); var attacker = new Signature(256); Global.GoofyPk = goofy.PublicKey; var trans1 = goofy.CreateCoin(attacker.PublicKey); //Action var sgndTrans1 = attacker.SignMessage(trans1); var destiny1 = new Person(); var transInfo1 = new TransferInfo(sgndTrans1, destiny1.PublicKey); var trans2 = trans1.PayTo(transInfo1); var destiny2 = new Person(); var transInfo2 = new TransferInfo(sgndTrans1, destiny2.PublicKey); var trans3 = trans1.PayTo(transInfo2); //Assert try { //!previousTransSignedByMe.isValidSignedMsg(previous); if ((trans2.isValidSignedMsg(trans2[trans1])) && (trans3.isValidSignedMsg(trans3[trans1]))) throw new Exception("Its not allowed to double spend the same coin."); } catch (Exception e) { Console.WriteLine(e.Message); } }
/// <summary> /// Constructor for the <c>ElementLabel</c> object. This is /// used to create a label that can convert a XML node into a /// composite object or a primitive type from an XML element. /// </summary> /// <param name="contact"> /// this is the field that this label represents /// </param> /// <param name="label"> /// this is the annotation for the contact /// </param> public ElementLabel(Contact contact, Element label) { this.detail = new Signature(contact, this); this.decorator = new Qualifier(contact); this.type = contact.Type; this.name = label.name(); this.label = label; }
public static void GoofyCreateAndTansferCoin_SouldHaveValidCoin() { //Arrange var signature = new Signature(256); Global.GoofyPk = signature.PublicKey; var coin = new Coin(signature); //Act var trans = new Transaction(coin, new Signature(256).PublicKey); //Assert try { //trans.CheckTransaction(); if (!coin.isGoofyCoin()) throw new Exception("This coin doenst belong to Goofy"); if (!coin.isValidSignature()) throw new Exception("This coin signature is invalid"); } catch (Exception e) { Console.WriteLine(e.Message); } }
public static void DoubleSpendAttach_SouldHaveValidTransactionChain() { //Arrange var goofy = new Goofy(); var person1 = new Signature(256); var person2 = new Person(); var person3 = new Person(); Global.GoofyPk = goofy.PublicKey; var trans1 = goofy.CreateCoin(person1.PublicKey); //Action var sgndTrans1 = person1.SignMessage(trans1); var trans2 = trans1.Payto(sgndTrans1, person2.PublicKey); var trans3 = trans1.Payto(sgndTrans1, person3.PublicKey); //Assert try { trans2.CheckTransaction(); trans3.CheckTransaction(); } catch (Exception e) { Console.WriteLine(e.Message); } }
public int AddSignatrue(string title, string content) { Signature sign = new Signature(); sign.SeqNo = int.Parse(Session["SeqNo"].ToString()); sign.Title = ""; sign.Content = content; return SignatureDal.Insert(sign); }
public ChangeSet Commit(string authorName, string message) { // REVIEW: Should we loop over all files and stage unstaged ones? var signature = new Signature(authorName, authorName, DateTimeOffset.UtcNow); Commit commit = Repository.Commit(signature, signature, message); return CreateChangeSet(commit); }
//[Fact] //public void CreatesReleaseNotesForClosedGitHubIssues() //{ // var commit = CreateCommit("Fixes JIRA-5", DateTimeOffset.Now.AddDays(-1)); // var commitsToScan = new List<Commit> { commit }; // var toScan = new Dictionary<ReleaseInfo, List<Commit>> // { // {new ReleaseInfo(), commitsToScan} // }; // _jiraApi // .GetClosedIssues(Arg.Any<GitReleaseNotesArguments>(), null) // .Returns(new List<OnlineIssue> // { // new OnlineIssue // { // Id = "JIRA-5", // Title = "Issue Title" // } // }); // var releaseNotes = _sut.ScanCommitMessagesForReleaseNotes(new GitReleaseNotesArguments // { // JiraServer = "http://my.jira.net", // JiraProjectId = "JIRA" // }, toScan); // Assert.Equal("Issue Title", releaseNotes.Releases[0].ReleaseNoteLines[0].Title); //} private static Commit CreateCommit(string message, DateTimeOffset when) { var commit = Substitute.For<Commit>(); commit.Message.Returns(message); var commitSignature = new Signature("Jake", "", when); commit.Author.Returns(commitSignature); return commit; }
public override void ReadServer (TlsBuffer incoming) { P = incoming.ReadBytes (incoming.ReadInt16 ()); G = incoming.ReadBytes (incoming.ReadInt16 ()); Y = incoming.ReadBytes (incoming.ReadInt16 ()); Signature = Signature.Read (protocol, incoming); }
public override int GetHashCode() { return(Signature.GetHashCode()); }
public void MergeTwoDifferentPropertiesWithMigrationChanged(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, IFixture fixture, Signature signature, string message) { // master: A-----D-----E---F // \ / / // \ ,---' / // \ / x / // newBranch: B---C---' (B contains a non-idempotent migration) // Arrange var a = container.AddRepository(sut, signature, message); // A // B, C a = container.Checkout(sut.Id, "newBranch", createNewBranch: true); var updatedInstance = a.With(c => c.Add(a, r => r.Migrations, fixture.Create <DummyMigration>())); var b = container.Commit(updatedInstance, signature, message); // B Assert.That(b.Migrations.Count, Is.GreaterThan(0)); var updateName = b.With(b.Applications[1].Pages[1], p => p.Name, "modified name"); container.Commit(updateName.Repository, signature, message); // C // D a = container.Checkout(sut.Id, "master"); var updateDescription = a.With(a.Applications[0].Pages[0], p => p.Description, "modified description"); container.Commit(updateDescription.Repository, signature, message); // D // E var mergeStep1 = container.Merge(sut.Id, "newBranch"); Assert.That(mergeStep1.IsPartialMerge, Is.True); mergeStep1.Apply(signature); // E // F var mergeStep2 = container.Merge(sut.Id, "newBranch"); Assert.That(mergeStep2.IsPartialMerge, Is.False); mergeStep2.Apply(signature); // F }
public void MergeSamePropertyConflict(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message, ComputeTreeChangesFactory computeTreeChangesFactory) { // master: A---C---D // \ / // newBranch: B---' // Arrange var a = container.AddRepository(sut, signature, message); // A // Act a = container.Checkout(sut.Id, "newBranch", createNewBranch: true); var updateName = a.With(a.Applications[0].Pages[0], p => p.Name, "modified name"); container.Commit(updateName.Repository, signature, message); // B a = container.Checkout(sut.Id, "master"); var updateNameOther = a.With(a.Applications[0].Pages[0], p => p.Name, "yet again modified name"); var commitC = container.Commit(updateNameOther.Repository, signature, message); // C var merge = container.Merge(sut.Id, "newBranch"); var chunk = merge.ModifiedProperties.Single(); chunk.Resolve("merged name"); var mergeCommit = merge.Apply(signature); // D // Assert var changes = computeTreeChangesFactory(container, container[sut.Id].RepositoryDescription) .Compare(commitC.CommitId, mergeCommit) .SkipIndexChanges(); Assert.That(changes, Has.Count.EqualTo(1)); Assert.That(changes[0].Status, Is.EqualTo(ChangeKind.Modified)); Assert.That(changes[0].Old.Name, Is.EqualTo("yet again modified name")); Assert.That(changes[0].New.Name, Is.EqualTo("merged name")); }
public void MergeFileAdditionChange(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, IServiceProvider serviceProvider, Signature signature, string message, ComputeTreeChangesFactory computeTreeChangesFactory) { // master: A---C---D // \ / // newBranch: B---' // Arrange sut = container.AddRepository(sut, signature, message); // A // Act sut = container.Checkout(sut.Id, "newBranch", createNewBranch: true); var updateName = sut.With(c => c.Add(sut.Applications[0].Pages[0], p => p.Fields, new Field(serviceProvider, UniqueId.CreateNew(), "new field", FieldContent.Default))); container.Commit(updateName.Repository, signature, message); // B var a = container.Checkout(sut.Id, "master"); var updateDescription = a.With(a.Applications[0].Pages[0], p => p.Description, "modified description"); var commitC = container.Commit(updateDescription.Repository, signature, message); // C var mergeCommit = container.Merge(sut.Id, "newBranch").Apply(signature); // D // Assert var changes = computeTreeChangesFactory(container, container[sut.Id].RepositoryDescription) .Compare(commitC.CommitId, mergeCommit) .SkipIndexChanges(); Assert.That(changes, Has.Count.EqualTo(1)); Assert.That(changes[0].Status, Is.EqualTo(ChangeKind.Added)); Assert.That(changes[0].New.Name, Is.EqualTo("new field")); }
public async Task <IActionResult> Edit(int id, SignatureEditViewModel signature) { if (id != signature.Id) { Response.StatusCode = 404; return(View("SignaturesNotFound")); } if (ModelState.IsValid) { string filenameForEdit = null; string uniqFileName = null; if (signature.SignaturePhoto != null && signature.SignaturePhoto.Length > 0) { string filePathForDelete = Path.Combine(_ihostingEnvironment.WebRootPath, "img/signatures", signature.SignaturePhotoExists); System.IO.File.Delete(filePathForDelete); if (IsFileValidate(signature.SignaturePhoto.FileName)) { string uplouadsFolder = Path.Combine(_ihostingEnvironment.WebRootPath, "img/signatures"); uniqFileName = Guid.NewGuid().ToString() + "_" + signature.SignaturePhoto.FileName; string filePath = Path.Combine(uplouadsFolder, uniqFileName); using (var fileStream = new FileStream(filePath, FileMode.Create)) { signature.SignaturePhoto.CopyTo(fileStream); } } else { ViewBag.msg = "الصور المسموح بها يجب ان تكون بمتداد : " + "png , jpeg , jpg , gif , bmp "; ViewData["DegreeList"] = new SelectList(DegreeList(), "Name", "Name", signature.Degree); ViewData["JobsSignatorieId"] = new SelectList(_context.JobsSignatories, "Id", "Name", signature.JobsSignatorieId); ViewData["ValidUnValidList"] = new SelectList(ValidUnValidHelpr.ValidUnValidHelprList(), "Value", "Name", signature.Status); ViewData["UserId"] = new SelectList(_context.Users, "Id", "FullName", signature.UserId); return(View(signature)); } } filenameForEdit = uniqFileName == null ? signature.SignaturePhotoExists : uniqFileName; Signature signatureforSave = new Signature() { UserId = signature.UserId, SignaturePhoto = filenameForEdit, Id = id, Degree = signature.Degree, JobsSignatorieId = signature.JobsSignatorieId, Status = signature.Status }; if (!SignatureExists(id, signature.UserId)) { if (SignatureExists(signature.UserId)) { ViewData["SignatureExists"] = "لايمكن اضافة توقيع آخر / يملك توقيع مسبقا!!"; ViewData["DegreeList"] = new SelectList(DegreeList(), "Name", "Name", signature.Degree); ViewData["JobsSignatorieId"] = new SelectList(_context.JobsSignatories, "Id", "Name", signature.JobsSignatorieId); ViewData["ValidUnValidList"] = new SelectList(ValidUnValidHelpr.ValidUnValidHelprList(), "Value", "Name", signature.Status); ViewData["UserId"] = new SelectList(_context.Users, "Id", "FullName", signature.UserId); return(View(signature)); } } _context.Update(signatureforSave); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["DegreeList"] = new SelectList(DegreeList(), "Name", "Name", signature.Degree); ViewData["JobsSignatorieId"] = new SelectList(_context.JobsSignatories, "Id", "Name", signature.JobsSignatorieId); ViewData["ValidUnValidList"] = new SelectList(ValidUnValidHelpr.ValidUnValidHelprList(), "Value", "Name", signature.Status); ViewData["UserId"] = new SelectList(_context.Users, "Id", "FullName", signature.UserId); return(View(signature)); }
/// <inheritdoc /> public MergeResult Merge(Branch branch, Signature merger, MergeOptions options) => repository.Merge(branch, merger, options);
/// <inheritdoc /> public MergeResult Merge(string committish, Signature merger, MergeOptions options) => repository.Merge(committish, merger, options);
/// <inheritdoc /> public MergeResult MergeFetchedRefs(Signature merger, MergeOptions options) => repository.MergeFetchedRefs(merger, options);
// Sign an XML file and save the signature in a new file. public static void SignXmlFile(string FileName, string SignedFileName, RSA Key) { // Check the arguments. if (FileName == null) { throw new ArgumentNullException("FileName"); } if (SignedFileName == null) { throw new ArgumentNullException("SignedFileName"); } if (Key == null) { throw new ArgumentNullException("Key"); } // Create a new XML document. XmlDocument doc = new XmlDocument(); // Format the document to ignore white spaces. doc.PreserveWhitespace = false; // Load the passed XML file using it's name. doc.Load(new XmlTextReader(FileName)); // Create a SignedXml object. SignedXml signedXml = new SignedXml(doc); // Add the key to the SignedXml document. signedXml.SigningKey = Key; // Get the signature object from the SignedXml object. Signature XMLSignature = signedXml.Signature; // Create a reference to be signed. Pass "" // to specify that all of the current XML // document should be signed. Reference reference = new Reference(""); // Add an enveloped transformation to the reference. XmlDsigEnvelopedSignatureTransform env = new XmlDsigEnvelopedSignatureTransform(); reference.AddTransform(env); // Add the Reference object to the Signature object. XMLSignature.SignedInfo.AddReference(reference); // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). KeyInfo keyInfo = new KeyInfo(); keyInfo.AddClause(new RSAKeyValue((RSA)Key)); // Add the KeyInfo object to the Reference object. XMLSignature.KeyInfo = keyInfo; // Compute the signature. signedXml.ComputeSignature(); // Get the XML representation of the signature and save // it to an XmlElement object. XmlElement xmlDigitalSignature = signedXml.GetXml(); // Append the element to the XML document. doc.DocumentElement.AppendChild(doc.ImportNode(xmlDigitalSignature, true)); if (doc.FirstChild is XmlDeclaration) { doc.RemoveChild(doc.FirstChild); } // Save the signed XML document to a file specified // using the passed string. XmlTextWriter xmltw = new XmlTextWriter(SignedFileName, new UTF8Encoding(false)); doc.WriteTo(xmltw); xmltw.Close(); }
/// <inheritdoc /> public CherryPickResult CherryPick(Commit commit, Signature committer, CherryPickOptions options) => repository.CherryPick(commit, committer, options);
private OcspReq GenerateRequest( DerObjectIdentifier signingAlgorithm, AsymmetricKeyParameter privateKey, X509Certificate[] chain, SecureRandom random) { Asn1EncodableVector requests = new Asn1EncodableVector(); foreach (RequestObject reqObj in list) { try { requests.Add(reqObj.ToRequest()); } catch (Exception e) { throw new OcspException("exception creating Request", e); } } TbsRequest tbsReq = new TbsRequest(requestorName, new DerSequence(requests), requestExtensions); ISigner sig = null; Signature signature = null; if (signingAlgorithm != null) { if (requestorName == null) { throw new OcspException("requestorName must be specified if request is signed."); } try { sig = SignerUtilities.GetSigner(signingAlgorithm.Id); if (random != null) { sig.Init(true, new ParametersWithRandom(privateKey, random)); } else { sig.Init(true, privateKey); } } catch (Exception e) { throw new OcspException("exception creating signature: " + e, e); } DerBitString bitSig = null; try { byte[] encoded = tbsReq.GetEncoded(); sig.BlockUpdate(encoded, 0, encoded.Length); bitSig = new DerBitString(sig.GenerateSignature()); } catch (Exception e) { throw new OcspException("exception processing TBSRequest: " + e, e); } AlgorithmIdentifier sigAlgId = new AlgorithmIdentifier(signingAlgorithm, DerNull.Instance); if (chain != null && chain.Length > 0) { Asn1EncodableVector v = new Asn1EncodableVector(); try { for (int i = 0; i != chain.Length; i++) { v.Add( X509CertificateStructure.GetInstance( Asn1Object.FromByteArray(chain[i].GetEncoded()))); } } catch (IOException e) { throw new OcspException("error processing certs", e); } catch (CertificateEncodingException e) { throw new OcspException("error encoding certs", e); } signature = new Signature(sigAlgId, bitSig, new DerSequence(v)); } else { signature = new Signature(sigAlgId, bitSig); } } return(new OcspReq(new OcspRequest(tbsReq, signature))); }
public override void ExitFunctionDecl(GoParser.FunctionDeclContext context) { bool signatureOnly = context.block() is null; FunctionSignature function = m_currentFunction.Signature; bool hasDefer = m_currentFunction.HasDefer; bool hasPanic = m_currentFunction.HasPanic; bool hasRecover = m_currentFunction.HasRecover; bool useFuncExecutionContext = hasDefer || hasPanic || hasRecover; Signature signature = function.Signature; string parametersSignature = $"({signature.GenerateParametersSignature(useFuncExecutionContext)})"; string resultSignature = signature.GenerateResultSignature(); // Replace function markers m_targetFile.Replace(m_functionResultTypeMarker, resultSignature); m_targetFile.Replace(m_functionParametersMarker, parametersSignature); if (useFuncExecutionContext) { string[] funcExecContextByRefParams = signature.GetByRefParameters(false).ToArray(); Stack <string> unusedNames = new Stack <string>(new[] { "__", "_" }); if (funcExecContextByRefParams.Length > 0) { string[] lambdaByRefParameters = signature.GetByRefParameters(true).ToArray(); m_targetFile.Replace(m_functionExecContextMarker, $" => func({string.Join(", ", funcExecContextByRefParams)}, ({string.Join(", ", lambdaByRefParameters)}, Defer {(hasDefer ? "defer" : unusedNames.Pop())}, Panic {(hasPanic ? "panic" : unusedNames.Pop())}, Recover {(hasRecover ? "recover" : unusedNames.Pop())}) =>"); } else { m_targetFile.Replace(m_functionExecContextMarker, $" => func(({(hasDefer ? "defer" : unusedNames.Pop())}, {(hasPanic ? "panic" : unusedNames.Pop())}, {(hasRecover ? "recover" : unusedNames.Pop())}) =>"); } } else { m_targetFile.Replace(m_functionExecContextMarker, ""); } string blockPrefix = ""; if (!signatureOnly) { // TODO: Double check if any other types need clone-type copy operations // For any array parameters, Go copies the array by value StringBuilder arrayClones = new StringBuilder(); foreach (ParameterInfo parameter in signature.Parameters) { if (parameter.Type.TypeClass == TypeClass.Array) { arrayClones.AppendLine($"{Spacing(1)}{parameter.Name} = {parameter.Name}.Clone();"); } } if (arrayClones.Length > 0) { arrayClones.Insert(0, Environment.NewLine); blockPrefix = arrayClones.ToString(); } } m_targetFile.Replace(string.Format(FunctionBlockPrefixMarker, m_currentFunctionName), blockPrefix); m_currentFunction = null; m_currentFunctionName = null; m_originalFunctionName = null; m_inFunction = false; if (useFuncExecutionContext) { m_targetFile.Append(");"); } else if (signatureOnly) { m_targetFile.Append(";"); } m_targetFile.Append(CheckForCommentsRight(context)); }
public override int GetHashCode() { return(ByteUtil.CalculateHashCode(Signature.ToArray())); }
/// <inheritdoc /> public MergeResult Merge(Commit commit, Signature merger, MergeOptions options) => repository.Merge(commit, merger, options);
public void MergeFileDeletionChange(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message, ComputeTreeChangesFactory computeTreeChangesFactory) { // master: A---C---D // \ / // newBranch: B---' // Arrange var a = container.AddRepository(sut, signature, message); // A // Act a = container.Checkout(a.Id, "newBranch", createNewBranch: true); var page = a.Applications[0].Pages[0]; var updateName = a.With(c => c.Remove(page, p => p.Fields, page.Fields[1])); container.Commit(updateName, signature, message); // B a = container.Checkout(a.Id, "master"); var updateDescription = a.With(a.Applications[0].Pages[0], p => p.Description, "modified description"); var commitC = container.Commit(updateDescription.Repository, signature, message); // C var mergeCommit = container.Merge(sut.Id, "newBranch").Apply(signature); // D // Assert var changes = computeTreeChangesFactory(container, container[sut.Id].RepositoryDescription) .Compare(commitC.CommitId, mergeCommit) .SkipIndexChanges(); Assert.That(changes, Has.Count.EqualTo(1)); Assert.That(changes[0].Status, Is.EqualTo(ChangeKind.Deleted)); Assert.That(changes[0].Old.Id, Is.EqualTo(page.Fields[1].Id)); }
/// <inheritdoc /> public RevertResult Revert(Commit commit, Signature reverter, RevertOptions options) => repository.Revert(commit, reverter, options);
/// <inheritdoc /> public Commit Commit(string message, Signature author, Signature committer, CommitOptions options) => repository.Commit(message, author, committer, options);
public Stash Stash() { Signature s = GetCurrentSignature(); return(Repository.Stashes.Add(s)); }
public void MergeTwoDifferentPropertiesChanged(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message, ComputeTreeChangesFactory computeTreeChangesFactory) { // master: A---C---D // \ / // newBranch: B---' // Arrange sut = container.AddRepository(sut, signature, message); // A // Act sut = container.Checkout(sut.Id, "newBranch", createNewBranch: true); var updateName = sut.With(sut.Applications[0].Pages[0], p => p.Name, "modified name"); container.Commit(updateName.Repository, signature, message); // B var a = container.Checkout(sut.Id, "master"); var updateDescription = a.With(a.Applications[0].Pages[0], p => p.Description, "modified description"); var commitC = container.Commit(updateDescription.Repository, signature, message); // C var mergeCommit = container.Merge(sut.Id, "newBranch").Apply(signature); // D // Assert var changes = computeTreeChangesFactory(container, container[sut.Id].RepositoryDescription) .Compare(commitC.CommitId, mergeCommit) .SkipIndexChanges(); Assert.That(changes, Has.Count.EqualTo(1)); Assert.That(changes[0].Status, Is.EqualTo(ChangeKind.Modified)); Assert.That(changes[0].Old.Name, Is.EqualTo(sut.Applications[0].Pages[0].Name)); Assert.That(changes[0].New.Name, Is.EqualTo(updateName.Name)); }
public Stash Stash(string message) { Signature s = GetCurrentSignature(); return(Repository.Stashes.Add(s, message)); }
public void PullRequiringMerge(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, IObjectRepositoryContainerFactory containerFactory, Signature signature, string message) { // Arrange sut = container.AddRepository(sut, signature, message); var tempPath = RepositoryFixture.GetAvailableFolderPath(); var clientContainer = containerFactory.Create <ObjectRepository>(tempPath); clientContainer.Clone(container.Repositories.Single().RepositoryDescription.Path); // Arrange - Update source repository var change = sut.With(sut.Applications[0].Pages[0], p => p.Description, "foo"); sut = container.Commit(change.Repository, signature, message); // Arrange - Update client repository var clientChange = sut.With(sut.Applications[0].Pages[0], p => p.Name, "bar"); clientContainer.Commit(clientChange.Repository, signature, message); // Act var pullResult = clientContainer.Pull(clientContainer.Repositories.Single().Id); pullResult.Apply(signature); // Assert Assert.That(pullResult.RequiresMergeCommit, Is.True); Assert.That(clientContainer.Repositories.Single().Applications[0].Pages[0].Description, Is.EqualTo("foo")); }
public void Commit(BranchLabelModel l, string message) { Signature s = GetCurrentSignature(); Commit c = Repository.Commit(message, s, s); }
public void MergeSamePropertyDetectsConflicts(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message) { // master: A---C---D // \ / // newBranch: B---' // Arrange var a = container.AddRepository(sut, signature, message); // A // Act a = container.Checkout(sut.Id, "newBranch", createNewBranch: true); var updateName = a.With(a.Applications[0].Pages[0], p => p.Name, "modified name"); container.Commit(updateName.Repository, signature, message); // B a = container.Checkout(sut.Id, "master"); var updateNameOther = a.With(a.Applications[0].Pages[0], p => p.Name, "yet again modified name"); container.Commit(updateNameOther.Repository, signature, message); // C Assert.Throws <RemainingConflictsException>(() => container.Merge(sut.Id, "newBranch").Apply(signature)); }
public Transaction Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (rlpStream.IsNextItemNull()) { rlpStream.ReadByte(); return(null); } var transactionSequence = rlpStream.PeekNextItem(); int transactionLength = rlpStream.ReadSequenceLength(); int lastCheck = rlpStream.Position + transactionLength; Transaction transaction = new Transaction(); transaction.Nonce = rlpStream.DecodeUInt256(); transaction.GasPrice = rlpStream.DecodeUInt256(); transaction.GasLimit = rlpStream.DecodeLong(); transaction.To = rlpStream.DecodeAddress(); transaction.Value = rlpStream.DecodeUInt256(); if (transaction.To == null) { transaction.Init = rlpStream.DecodeByteArray(); } else { transaction.Data = rlpStream.DecodeByteArray(); } if (rlpStream.Position < lastCheck) { Span <byte> vBytes = rlpStream.DecodeByteArraySpan(); Span <byte> rBytes = rlpStream.DecodeByteArraySpan(); Span <byte> sBytes = rlpStream.DecodeByteArraySpan(); bool allowUnsigned = (rlpBehaviors & RlpBehaviors.AllowUnsigned) == RlpBehaviors.AllowUnsigned; bool isSignatureOk = true; string signatureError = null; if (vBytes == null || rBytes == null || sBytes == null) { isSignatureOk = false; signatureError = "VRS null when decoding Transaction"; } else if (vBytes.Length == 0 || rBytes.Length == 0 || sBytes.Length == 0) { isSignatureOk = false; signatureError = "VRS is 0 length when decoding Transaction"; } else if (vBytes[0] == 0 || rBytes[0] == 0 || sBytes[0] == 0) { isSignatureOk = false; signatureError = "VRS starting with 0"; } else if (rBytes.Length > 32 || sBytes.Length > 32) { isSignatureOk = false; signatureError = "R and S lengths expected to be less or equal 32"; } else if (rBytes.SequenceEqual(Bytes.Zero32) && sBytes.SequenceEqual(Bytes.Zero32)) { isSignatureOk = false; signatureError = "Both 'r' and 's' are zero when decoding a transaction."; } if (isSignatureOk) { int v = vBytes.ReadEthInt32(); Signature signature = new Signature(rBytes, sBytes, v); transaction.Signature = signature; transaction.Hash = Keccak.Compute(transactionSequence); } else { if (!allowUnsigned) { throw new RlpException(signatureError); } } } if ((rlpBehaviors & RlpBehaviors.AllowExtraData) != RlpBehaviors.AllowExtraData) { rlpStream.Check(lastCheck); } return(transaction); }
public void CanCommitALittleBit() { string repoPath = InitNewRepository(); var identity = Constants.Identity; using (var repo = new Repository(repoPath, new RepositoryOptions { Identity = identity })) { string dir = repo.Info.Path; Assert.True(Path.IsPathRooted(dir)); Assert.True(Directory.Exists(dir)); const string relativeFilepath = "new.txt"; string filePath = Touch(repo.Info.WorkingDirectory, relativeFilepath, "null"); Commands.Stage(repo, relativeFilepath); File.AppendAllText(filePath, "token\n"); Commands.Stage(repo, relativeFilepath); Assert.Null(repo.Head[relativeFilepath]); var author = Constants.Signature; const string shortMessage = "Initial egotistic commit"; const string commitMessage = shortMessage + "\n\nOnly the coolest commits from us"; var before = DateTimeOffset.Now.TruncateMilliseconds(); Commit commit = repo.Commit(commitMessage, author, author); AssertBlobContent(repo.Head[relativeFilepath], "nulltoken\n"); AssertBlobContent(commit[relativeFilepath], "nulltoken\n"); Assert.Empty(commit.Parents); Assert.False(repo.Info.IsHeadUnborn); // Assert a reflog entry is created on HEAD Assert.Single(repo.Refs.Log("HEAD")); var reflogEntry = repo.Refs.Log("HEAD").First(); Assert.Equal(identity.Name, reflogEntry.Committer.Name); Assert.Equal(identity.Email, reflogEntry.Committer.Email); var now = DateTimeOffset.Now; Assert.InRange(reflogEntry.Committer.When, before, now); Assert.Equal(commit.Id, reflogEntry.To); Assert.Equal(ObjectId.Zero, reflogEntry.From); Assert.Equal(string.Format("commit (initial): {0}", shortMessage), reflogEntry.Message); // Assert a reflog entry is created on HEAD target var targetCanonicalName = repo.Refs.Head.TargetIdentifier; Assert.Single(repo.Refs.Log(targetCanonicalName)); Assert.Equal(commit.Id, repo.Refs.Log(targetCanonicalName).First().To); File.WriteAllText(filePath, "nulltoken commits!\n"); Commands.Stage(repo, relativeFilepath); var author2 = new Signature(author.Name, author.Email, author.When.AddSeconds(5)); Commit commit2 = repo.Commit("Are you trying to fork me?", author2, author2); AssertBlobContent(repo.Head[relativeFilepath], "nulltoken commits!\n"); AssertBlobContent(commit2[relativeFilepath], "nulltoken commits!\n"); Assert.Single(commit2.Parents); Assert.Equal(commit.Id, commit2.Parents.First().Id); // Assert the reflog is shifted Assert.Equal(2, repo.Refs.Log("HEAD").Count()); Assert.Equal(reflogEntry.To, repo.Refs.Log("HEAD").First().From); Branch firstCommitBranch = repo.CreateBranch("davidfowl-rules", commit); Commands.Checkout(repo, firstCommitBranch); File.WriteAllText(filePath, "davidfowl commits!\n"); var author3 = new Signature("David Fowler", "*****@*****.**", author.When.AddSeconds(2)); Commands.Stage(repo, relativeFilepath); Commit commit3 = repo.Commit("I'm going to branch you backwards in time!", author3, author3); AssertBlobContent(repo.Head[relativeFilepath], "davidfowl commits!\n"); AssertBlobContent(commit3[relativeFilepath], "davidfowl commits!\n"); Assert.Single(commit3.Parents); Assert.Equal(commit.Id, commit3.Parents.First().Id); AssertBlobContent(firstCommitBranch[relativeFilepath], "nulltoken\n"); } }
public SignDailyStockUsed(DetailedTabs tabs) : base(tabs) { // todo :: EXCEPTION HANDLING here // fill the DVC property here with the stock details dvc = new DialogViewController(new RootElement("Used stock")); dvc.Root.Add(new Section("")); if (File.Exists(ServerClientViewController.dbFilePath)) { // read the data from database here using (var connection = new SqliteConnection("Data Source=" + ServerClientViewController.dbFilePath)) { try { using (var cmd = connection.CreateCommand()) { connection.Open(); cmd.CommandText = "SELECT su.Element_Type as Type, su.Element_OID as ID, p.Part_Desc as Desc, SUM(su.Num_Used) as USED_TODAY " + "FROM STOCKUSED su, PARTS p " + "WHERE su.Element_OID = p.Part_ID " + "AND su.Element_Type = 'P' " + "GROUP BY Element_Type, Element_OID, Part_Desc " + "UNION SELECT su.Element_Type as Type, su.Element_OID as ID, a.Name as Desc, SUM(su.Num_Used) as USED_TODAY " + "FROM STOCKUSED su, ASSEMBLIES a " + "WHERE su.Element_OID = a.Assembly_ID " + "AND su.Element_Type = 'A' " + "GROUP BY Element_Type, Element_OID, Name"; using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { string id = (string)(reader["type"]) + Convert.ToString(reader["id"]); string description = (string)reader["desc"]; double used = Convert.ToDouble(reader["used_today"]); dvc.Root[0].Add(new StyledStringElement( id + " " + description, used.ToString(), UITableViewCellStyle.Value1)); } if (!reader.IsClosed) { reader.Close(); } } } } catch (Exception e) { // Console.WriteLine (e.Message); } } } GenerateStockUsedPDFPreview(); RedrawDailyStockPDF(false); GoBack = delegate { if (SigningMode) { FinishSigning(null, null); hasBeenSigned = false; } this.NavigationController.PopToRootViewController(true); }; GoForward = delegate { if (this.hasBeenSigned) { this.NavigationController.SetNavigationBarHidden(true, false); this.NavigationController.PopToRootViewController(true); this.Tabs._scView.StartNewDataExchange(); // this.Tabs._scView.InitDataExchange (); } else { var alert = new UIAlertView("", "Please finish signing the document first", null, "OK"); alert.Show(); } }; ClearSignature = delegate { // Signature.Image = new UIImage(); Signature.Clear(); hasBeenSigned = false; }; StartSigning = delegate { signing = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, FinishSigning); this.SetToolbarItems(new UIBarButtonItem[] { back, new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), clearSignature, new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), signing, new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), forward }, true); // Signature.Image = new UIImage(); Signature.Clear(); hasBeenSigned = false; SigningMode = true; }; FinishSigning = delegate { SigningMode = false; signing = new UIBarButtonItem("Start signing", UIBarButtonItemStyle.Bordered, StartSigning); this.SetToolbarItems(new UIBarButtonItem[] { back, new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), signing, new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), forward }, true); UIImageView iv = new UIImageView(); iv = (UIImageView)GeneratedPDFView.ViewWithTag(4); iv.ContentMode = UIViewContentMode.ScaleAspectFit; UIImage im = Signature.GetDrawingImage(); // this.Signature.Image; iv.Image = im; if (hasBeenSigned) { RedrawDailyStockPDF(true); CGPoint offset = new CGPoint(0, this.PDFView.ScrollView.ContentSize.Height - this.PDFView.ScrollView.Bounds.Height); PDFView.ScrollView.SetContentOffset(offset, true); // Signature.Image = new UIImage(); Signature.Clear(); } iv.Dispose(); im.Dispose(); im = null; iv = null; }; back = new UIBarButtonItem(UIBarButtonSystemItem.Reply); signing = new UIBarButtonItem("Start signing", UIBarButtonItemStyle.Plain, StartSigning); forward = new UIBarButtonItem(UIBarButtonSystemItem.Action); clearSignature = new UIBarButtonItem("Clear signature", UIBarButtonItemStyle.Plain, ClearSignature); ToolbarItems = new UIBarButtonItem[] { back, new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), signing, new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), forward }; back.Clicked += GoBack; forward.Clicked += GoForward; }
/// <summary> /// Saves a png image file to the specified <paramref name="path"/>. /// </summary> /// <param name="signature">Input signature containing <see cref="Features.Image"/>.</param> /// <param name="path">Output file path of the png image.</param> public static void Save(Signature signature, string path) { Image <Rgba32> img = signature.GetFeature(Features.Image); img.SaveAsPng(File.Create(path)); }
override public bool VerifySignature(byte[] message, BigInteger[] publicKeys, Signature signature) { var L = ConcatInts(null, publicKeys); var h = Hash2(L); var prefix = ConcatInts(L, signature.Ytilda).Concat(message); var c = signature.C1; BigInteger zDash, z2Dash; for (int i = 0; i < publicKeys.Length; ++i) { zDash = (mod.Pow(GroupParameters.Generator, signature.S[i]) * mod.Pow(publicKeys[i], c)).Mod(GroupParameters.Prime); z2Dash = (mod.Pow(h, signature.S[i]) * mod.Pow(signature.Ytilda, c)).Mod(GroupParameters.Prime); c = Hash1(ConcatInts(prefix, zDash, z2Dash)); } return(signature.C1.Equals(c)); }
public Commit CommitToBranch(Repository repo, string branchName, string message, Signature author, Tree tree) { Branch branch = repo.Branches[branchName]; Commit commit = repo.ObjectDatabase.CreateCommit(author, author, message, tree, new List <Commit> { branch.Tip }, prettifyMessage: true); repo.Refs.UpdateTarget(repo.Refs[branch.CanonicalName], commit.Id); return(commit); }
private void Window_Closed(object sender, EventArgs e) { Signature.Dispose(); ExpenseMap.Dispose(); }