Hi there,
I am trying to create a decryption algorithm in monkey c.
This require a 96-bit key. I would like to have some ideas of how I can put that long key as an entry parameter in a function.
Thanks in advance
Regards,
Hi there,
I am trying to create a decryption algorithm in monkey c.
This require a 96-bit key. I would like to have some ideas of how I can put that long key as an entry parameter in a function.
Thanks in advance
Regards,
function dec(key) {}
where is the problem?
The key is 96 bits, which is too large to fit in a Number or Long.
I would like to have some ideas of how I can put that long key as…
If it's hard coded it has to be converted to any accepted type by MC so the best is what Jim said arrays of 96 bytes. But it depended on code inside the function.
- It's 96 bits, not 96…
function dec(key) {}
where is the problem?
function dec(key) {}
where is the problem?
The key is 96 bits, which is too large to fit in a Number or Long.
I would like to have some ideas of how I can put that long key as an entry parameter in a function.
You could try:
// key_2 = most significant 32-bits
// key_1 = middle 32-bits
// key_0 = least significant 32-bits
function decrypt(key_2 as Number, key_1 as Number, key_0 as Number, ...);
(Keep in mind Numbers are signed 32-bit integers and Garmin doesn't have unsigned right bit shift, so if you need that operation, you'll have to implement it yourself.)
// key[i] = ith byte of key
// (you decide whether k[0] should be the most significant or least significant byte)
// if you're decoding the key from a user-entered string, it might be easier to have k[0] as the MSB
function decrypt(key as Array<Number>, ...);
Nobody said it's a 96-bit number but key :)
Haha yeah if the key is in the form of a string then the answer is trivial but I assumed OP meant in the form of numerical data. Even if you pass the key as a string, at some point it needs to be turned into usable numbers…
A ByteArray instead of a String would allow getting the numeric value of each byte, and you can access things as 8 bit, 16 bit, or 32 bit signed or unsigned, or as a 32 bit float
I'm almost sure it's a string as usually.
But let's wait for OP because we will again debate between us about theory
Thanks, you understood my problem. This is a 96-bit number.
I will try to do something based on your and others comments.
A ByteArray instead of a String would allow getting the numeric value of each byte, and you can access things as 8 bit, 16 bit, or 32 bit signed or unsigned, or as a 32 bit float
If you actually read the thread and tried to understand the context, you would see that I was actually suggesting that OP was not looking for a solution that involves a String, and even if they were, they still need to eventually transform the key into numerical data anyway.
In fact I suggested 3 Numbers or an array of Numbers (a ByteArray would work just as well, but it's only available in CIQ 3 and higher.)
I'm almost sure it's a string as usually.
Yeah my point was that surely OP would not be asking us how to pass a string into a function, and even if they were, at some point that string needs to be represented as numerical data, so it doesn't hurt to try to answer the question in good faith anyway.
So how this 96-bit number come up on cig as ciq doesn't support such numbers? Hard coded?
I feel OP has c/java function that require 96b value and want to use it. So it means function has to be rewritten as there is no 96b int in ciq so parameters can be change also. And no problem with parameter but with rewrite func.
Dear OP explain problem in detail with code of type want help.