Giter Club home page Giter Club logo

Comments (3)

sgbj avatar sgbj commented on August 30, 2024

Sorry I haven't been able to get back with you, the weekend and work sort of snuck up on me.

I must confess that I don't know very much about WinRT. I'm wondering though if you could just do away with the cryptography API that comes with it and use Bouncy Castle's extensive collection of APIs used in cryptography instead? You can easily add it to your project through NuGet.

All you'd have to do is replace the Transform method with something like this:

using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Engines;
using Org.BouncyCastle.Crypto.Modes;
using Org.BouncyCastle.Crypto.Parameters;
using System;
using System.Numerics;
using System.Security.Cryptography;

...

public static BigInteger Transform(string name, bool encrypt, BigInteger key, BigInteger message)
{
    var cipher = new BufferedBlockCipher(new CbcBlockCipher(name == "TripleDES" ? new DesEdeEngine() : new DesEngine()));
    cipher.Init(encrypt, new KeyParameter(key.GetBytes()));
    var input = message.GetBytes();

    byte[] output = new byte[cipher.GetOutputSize(input.Length)];
    var bytesProcessed = cipher.ProcessBytes(input, 0, input.Length, output, 0);
    var outputLength = bytesProcessed;
    bytesProcessed = cipher.DoFinal(output, bytesProcessed);
    outputLength += bytesProcessed;
    var truncatedOutput = new byte[outputLength];
    Array.Copy(output, truncatedOutput, outputLength);

    return BigInt.FromBytes(truncatedOutput);
}

Let me know if this doesn't help you on your way. I'm interested in hearing about what you decide to do.

from dukpt.net.

benb1n avatar benb1n commented on August 30, 2024

@sgbj Thanks a million! That advice was golden. We brought in a WinRT port of Bouncy Castle from Nuget, updated the Transform to use your example code above, and it worked beautifully! Thanks again!

We'd like to contribute back to this project if possible. I'm curious if you'd like us to fork your repo and add a separate solution for the WinRT port, or if we should publish a separate repo for it.

from dukpt.net.

sgbj avatar sgbj commented on August 30, 2024

Glad I could help! It's cool that you'd like to contribute, but how you choose to do that is entirely up to you. If you want to fork it, I think that'd give us the added benefit of being able to pull each others changes more easily. But if you choose to make a separate repo for it that's cool too. Just link me to the page when you're done so I can refer people to it in my readme if that's ok with you.

from dukpt.net.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.