Giter Club home page Giter Club logo

Comments (5)

ichoes avatar ichoes commented on August 30, 2024

sorry forgot

  private static readonly BigInteger DEK_MASK = BigInt.FromHex("0000000000FF00000000000000FF0000");

from dukpt.net.

sgbj avatar sgbj commented on August 30, 2024

Based on the excerpt, your logic is correct. However, I specifically stayed away from using string concatenation to perform these calculations because of the way C#'s BigInteger handles signedness in hex, which can throw off your results very slightly. Besides, it's much more natural to represent recombining the left and right sides using bitwise operators.

Expanded:

var key = DeriveKey(ipek, ksn);
key = key ^ DekMask;
var left = (key & Ms16Mask) >> 64;
var right = (key & Ls16Mask);
left = Transform("TripleDES", true, key, left);
right = Transform("TripleDES", true, key, right);
var dek = left << 64 | right;
return dek;

Minified:

var key = DeriveKey(ipek, ksn) ^ DekMask;
return Transform("TripleDES", true, key, (key & Ms16Mask) >> 64) << 64 
     | Transform("TripleDES", true, key, (key & Ls16Mask));

Let me know if that works for you, otherwise I'll take a closer look at it.

from dukpt.net.

ichoes avatar ichoes commented on August 30, 2024

Hi, Yeah, i had the same result with the hex string.
i already got the solution and it works. same as your code.
Thanks,

On Thu, Jul 10, 2014 at 10:37 AM, sgbj [email protected] wrote:

Based on the excerpt, your logic is correct. However, I specifically
stayed away from using string concatenation to perform these calculations
because of the way C#'s BigInteger handles signedness in hex, which can
throw off your results very slightly. Besides, it's much more natural to
represent recombining the left and right sides using bitwise operators.

Expanded:

var key = DeriveKey(ipek, ksn);key = key ^ DekMask;var left = (key & Ms16Mask) >> 64;var right = (key & Ls16Mask);left = Transform("TripleDES", true, key, left);right = Transform("TripleDES", true, key, right);var dek = left << 64 | right;return dek;

Minified:

var key = DeriveKey(ipek, ksn) ^ DekMask;return Transform("TripleDES", true, key, (key & Ms16Mask) >> 64) << 64
| Transform("TripleDES", true, key, (key & Ls16Mask));

Let me know if that works for you, otherwise I'll take a closer look at it.


Reply to this email directly or view it on GitHub
#7 (comment).

Rafael Gonzalez
Developer
www.emobilepos.com

from dukpt.net.

SaddamBInSyed avatar SaddamBInSyed commented on August 30, 2024

Hi,
Where i should put this code,

var key = DeriveKey(ipek, ksn);
key = key ^ DekMask;
var left = (key & Ms16Mask) >> 64;
var right = (key & Ls16Mask);
left = Transform("TripleDES", true, key, left);
right = Transform("TripleDES", true, key, right);
var dek = left << 64 | right;
return dek;

pls reply

from dukpt.net.

SaddamBInSyed avatar SaddamBInSyed commented on August 30, 2024

Hi all,

finally it got worked.. Thanks to all .............bye

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.