Xively Device Activation Code does not match using HMAC-SHA1 algorithm - xively

I am trying to calculate the Activation Code from Product Secret and Device Serial Number, my calculated Activation Code is always different from Xively's.
Can someone please help me to point out where I am wrong?
From Xievely web portal:
Product ID: 4sA5tK9XF_3xKfOawmyO
Product Secret: be0f6928e3653cf175b7f8ebb2da50c6658b30b7
Serial Number: 123123123
Activation Code: 93d80b284a19d14e99d9abb7d637afc59d4b0f95
I tested with PHP:
echo hash_hmac("sha1","123123123","be0f6928e3653cf175b7f8ebb2da50c6658b30b7");
Activation code I generated is: 66b02f4c691287144c09e3b76816275742c155b5 which is different from Xively's.
Please help, thanks a million.

Provided that you are using PHP 5 you can convert the secret into binary using hex2bin() and this should work. Try this:
$secret_string='be0f6928e3653cf175b7f8ebb2da50c6658b30b7';
$secret=hex2bin($secret_string);
echo hash_hmac("sha1", '123123123',$secret)."\n";
if no PHP5 you can define hex2bin yourself.
Paul

Related

How can I to transmit at least a "couple of bytes" on the local network (UEFI DXE)

I need to write driver (DXE), that can transmit "couple of bytes" from virtual machine (QEMU) to the host system (OS - Ubuntu). I've read the UEFI_Spec and Guide for developers, but I still don't understand, how to write the code and what protocol should I use (tried to use TCPv4 but can't even LocateHandleBuffer).
EFI_STATUS Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiTcp4ProtocolGuid, NULL, &HandleCount, &HandleBuffer);
I get:
EFI_UNSUPPORTED
If somebody can explain me or can show examples of the code, I'll be very grateful. Thanks.
For most network related protocols you first have to use the corresponding "Service Binding Protocol" to get a handle which contains the protocol you are looking for.
Use this steps to access the Tcp4Protocol:
gBS->LocateHandleBuffer(ByProtovol,gEfiTcp4ServiceBindingProtocolGuid, NULL, &HandleCount, &HandleBuffer);
// Loop over the HandleBuffer Array and pick the one you need
gBS->HandleProtocol(HandleBuffer[YourIndex], &gEfiTcp4ServiceBindingProtocolGuid, &Tcp4SBProtocol);
Tcp4SBProtocol->CreateChild(Tcp4SBProtocol, &Tcp4Handle);
gBS->HandleProtocol(Tcp4Handle, &gEfiTcp4ProtocolGuid, &Tcp4Protocol);
To check if a NIC is available you can use:
// This should return EFI_SUCCESS
gBS->LocateProtocol(&gEfiSimpleNetworkProtocolGuid, NULL, &SimpleNetworkProtocol);
There is a complete code sample for the HttpProtocol inside the Uefi specification (starting at page 1548), the Tcp4Protocol is not very different.

Barcode types supported by jasonette vision api

I have a question regarding the $vision.scan action for scanning barcodes and hope someone could help me with that. Do we need to provide any particular option to be able to scan EAN 13 or EAN 8 barcodes? The example : (https://jasonbase.com/things/PMj7) is able to scan QR codes without any issues but isn't able to scan any other type of barcode. The gif in the $vision.scan documentation shows that a number of different types of barcodes are being scanned. Could it be a version issue? I'm using a Oneplus 5, running Android 8.1.0. Any help would be really appreciated.
Yes, you need to change some code in Android Studio.
In App > Java > com.jasonette.seed > Service > Vision > JasonVisionService.java
Find setBarcodeFormats.
detector = new BarcodeDetector.Builder(context)
// .setBarcodeFormats(Barcode.QR_CODE)
.setBarcodeFormats(Barcode.EAN_13 | Barcode.EAN_8)
.build();
In the above example I've commented out the QR_CODE format and instead added my own to scan EAN_8 and EAN_13.
More info:
https://developers.google.com/android/reference/com/google/android/gms/vision/barcode/BarcodeDetector.Builder

how to use telegram API codes?

i registered in https://my.telegram.org/apps and got api_hash and api_id and public key ,now i want to use this function https://core.telegram.org/method/auth.sendCode
auth.sentCode#efed51d9 phone_registered:Bool phone_code_hash:string send_call_timeout:int is_password:Bool = auth.SentCode;
auth.sentAppCode#e325edcf phone_registered:Bool phone_code_hash:string send_call_timeout:int is_password:Bool = auth.SentCode;
---functions---
auth.sendCode#768d5f4d phone_number:string sms_type:int api_id:int api_hash:string lang_code:string = auth.SentCode;
Query example
(auth.sendCode "79991234567" 1 32 "test-hash" "en")
=
(auth.sentCode
phone_registered:(boolFalse)
phone_code_hash:"2dc02d2cda9e615c84"
)
d16ff372 3939370b 33323139 37363534 00000001 00000020 73657409 61682d74 00006873 e77e812d
=
2215bcbd bc799737 63643212 32643230 39616463 35313665 00343863 e12b7901
how can i use this query example?
and what is this binaries? ==> "d16ff372 3939370b 33323139 ...."
You can't directly start to send queries to Telegram. Creating api_hash and api_id is a basic step to start with Telegram API. Hope you know that Telegram uses its own protocol called 'MTProto'. You can get the detailed discription in Telegram's official website.
As per Telegram Protocol, the Client and Server shares the 'Authorization Key' (which is used for encryption and decryption) using Diffie-Hellman algorithm. For sample please see https://core.telegram.org/mtproto/samples-auth_key. After creating the authorization key successfully, we can start to call Telegram APIs which is called as RPC queries.
You can also refer https://github.com/ex3ndr/telegram-api for implementation.
The hexadecimal data in the example is nothing but the query made by following the algorithm.
You need to start from making a valid Telegram AuthKey.
The patterns and functions you build up along the way while doing this will help you towards building the rest of your Telegram API.
You can start with this here: https://stackoverflow.com/a/32809138/44080
And them work up, step by step until you have the AuthKey as described in these links
https://core.telegram.org/mtproto/auth_key
https://core.telegram.org/mtproto/samples-auth_key
Part of the problem you will initially face is the documentation.
Working through this step by step and getting familiar with the authors writing style is a big help too.

How does link with href for Line and Wechat?

Do you know the protocol for Line and Wechat? I want to find link of Line and Wechat like yahoo(ymsgr:sendIM?userid) and skype(skype:userid?chat)
The protocol you are looking for is weixin://
We are currently aware of 2 different ways to call this:
weixin://contacts/profile/USERNAME - USERNAME is a variable
weixin://qr/DECODED_QR_CODE - DECODED_QR_CODE is the decoded version of a WeChat QR code.
* IMPORTANT NOTE: Please note this functionality has been deprecated*

how to parse customer message?

i use customer message and send it broadcast over radio channel, i use example 6 (CounterSend ) from this link .
when i build this project as micAz on mote 1, after this i use Xsniffer (TOSBase) on the mote that i will use it on the serial usb board (520).
after that i open Xsniffer program to see the radio packet and they appeared as following :
on other hand, to use Xserver i use XMeshBase then type on cygwin terminal :
xserve -device=com4
i got this!! but i can't understand what it received ?
how can i parse the data received ?? and named them as i want ?? ex: i need first byte be the source ??
how to do that ?

Resources