![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Callum and Adel's changes on 12/02/19
Dependencies: Crypto
Diff: main.cpp
- Revision:
- 14:4e312fb83330
- Parent:
- 12:41b3112021a3
- Child:
- 15:2f95f2fb68e3
diff -r d08bbfae7197 -r 4e312fb83330 main.cpp --- a/main.cpp Tue Mar 05 13:57:51 2019 +0000 +++ b/main.cpp Tue Mar 05 14:49:13 2019 +0000 @@ -1,4 +1,7 @@ +#include "SHA256.h" #include "mbed.h" +//#include <iostream> + //Photointerrupter input pins #define I1pin D3 @@ -113,8 +116,32 @@ //Main int main() { //Initialise the serial port - // Serial pc(SERIAL_TX, SERIAL_RX); - // pc.printf("Hello\n\r"); + Serial pc(SERIAL_TX, SERIAL_RX); + pc.printf("Hello\n\r"); + +// std::ios::sync_with_stdio(false); + SHA256::SHA256 Miner; + + uint8_t sequence[] = {0x45,0x6D,0x62,0x65,0x64,0x64,0x65,0x64, + 0x20,0x53,0x79,0x73,0x74,0x65,0x6D,0x73, + 0x20,0x61,0x72,0x65,0x20,0x66,0x75,0x6E, + 0x20,0x61,0x6E,0x64,0x20,0x64,0x6F,0x20, + 0x61,0x77,0x65,0x73,0x6F,0x6D,0x65,0x20, + 0x74,0x68,0x69,0x6E,0x67,0x73,0x21,0x20, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + uint64_t* key = (uint64_t*)((int)sequence + 48); + uint64_t* nonce = (uint64_t*)((int)sequence + 56); + uint8_t hash[32]; + uint32_t length64 = 64; + +// MD2::computeHash(hash, (uint8_t*)msg, strlen(msg)); + + Miner.computeHash(hash, sequence, length64); + pc.printf("hash: "); + for(int i = 0; i < 32; ++i) + printf("%02x", hash[i]); + printf("\n"); //Run the motor synchronisation orState = motorHome(); @@ -138,5 +165,6 @@ // Keep the program running indefinitely while (1); // {} // pc.printf("Current:%d \t Next:%d \n\r", currentState, (currentState-orState+lead+6)%6);} + }