From 804759607622f44057a5b2ee60b6d96289c37a82 Mon Sep 17 00:00:00 2001 From: KAbhijeet2105 Date: Tue, 25 Feb 2020 20:34:22 +0530 Subject: [PATCH 1/2] Added an example of random passkey generator for CRC32 library --- .../passkey_generator/passkey_generator.ino | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 examples/passkey_generator/passkey_generator.ino diff --git a/examples/passkey_generator/passkey_generator.ino b/examples/passkey_generator/passkey_generator.ino new file mode 100644 index 0000000..beeca01 --- /dev/null +++ b/examples/passkey_generator/passkey_generator.ino @@ -0,0 +1,70 @@ +/* CRC32.ino + * + * This sketch demonstrates how to use the Arduino_CRC32 + * library to calculate a CRC-32 checksum using a simple example of Random passkey suggester. + * + * Abhijeet Kadam + */ + +/************************************************************************************** + * INCLUDE + **************************************************************************************/ + +#include + +/************************************************************************************** + * GLOBAL VARIABLES + **************************************************************************************/ + +Arduino_CRC32 crc32; + +char str1; + +char const ex_msg[] = "My_PassKey"; //your message here + +long randNumber; + +uint32_t crc_code; + +uint32_t final_passkey; + +/************************************************************************************** + * SETUP/LOOP + **************************************************************************************/ + +void setup() +{ + Serial.begin(9600); + + + crc_code = crc32.calc((uint8_t const *)ex_msg, strlen(ex_msg)); // CRC code generation + + Serial.println("Welcome to Random passkey suggester enter y to continue.."); + Serial.println("NOTE: you can change your message in passkey_generator.ino"); + + + +} + +void loop() + { + if (Serial.available() > 0) + { + str1 =Serial.read(); // read the incoming: + + if(str1=='y'||str1=='Y') + { + + Serial.print("Your message : "); + Serial.println(ex_msg); + Serial.print("Your passkey suggestion : "); + + final_passkey = crc_code*random(30,4000)-random(5000); // passkey generation + + Serial.println(final_passkey); + Serial.println("Enter y for new passkey suggestion"); + Serial.println(); + + } + } + } From 08e23df172a837d3bf52782d1dbe61b097bbaa72 Mon Sep 17 00:00:00 2001 From: KAbhijeet2105 Date: Thu, 19 Mar 2020 14:25:08 +0530 Subject: [PATCH 2/2] Bug Fix --- .../PasskeyGenerator/PasskeyGenerator.ino | 55 +++++++++++++++ .../passkey_generator/passkey_generator.ino | 70 ------------------- 2 files changed, 55 insertions(+), 70 deletions(-) create mode 100644 examples/PasskeyGenerator/PasskeyGenerator.ino delete mode 100644 examples/passkey_generator/passkey_generator.ino diff --git a/examples/PasskeyGenerator/PasskeyGenerator.ino b/examples/PasskeyGenerator/PasskeyGenerator.ino new file mode 100644 index 0000000..cf87803 --- /dev/null +++ b/examples/PasskeyGenerator/PasskeyGenerator.ino @@ -0,0 +1,55 @@ +/* PasskeyGenerator.ino + + This sketch demonstrates how to use the Arduino_CRC32 + library to calculate a CRC-32 checksum using a simple example of Random passkey suggester. + + Written by Abhijeet Kadam +*/ + +/************************************************************************************** + INCLUDE + **************************************************************************************/ + +#include + +/************************************************************************************** + GLOBAL VARIABLES +**************************************************************************************/ + +Arduino_CRC32 crc32; + +char str1; + +char const ex_msg[] = "My_PassKey"; //your message here + +long randNumber; +uint32_t crc_code; +uint32_t final_passkey; +/************************************************************************************** + SETUP/LOOP + **************************************************************************************/ + +void setup() +{ + Serial.begin(9600); + crc_code = crc32.calc((uint8_t const *)ex_msg, strlen(ex_msg)); // CRC code generation +Serial.println("Welcome to Random passkey suggester enter y to continue.."); + Serial.println("NOTE: you can change your message in passkey_generator.ino"); +} +void loop() +{ + if (Serial.available() > 0) + { + str1 = Serial.read(); // read the incoming: + if (str1 == 'y' || str1 == 'Y') + { + Serial.print("Your message : "); + Serial.println(ex_msg); + Serial.print("Your passkey suggestion : "); + final_passkey = crc_code * random(30, 4000) - random(5000); // passkey generation + Serial.println(final_passkey); + Serial.println("Enter y for new passkey suggestion"); + Serial.println(); + } + } +} diff --git a/examples/passkey_generator/passkey_generator.ino b/examples/passkey_generator/passkey_generator.ino deleted file mode 100644 index beeca01..0000000 --- a/examples/passkey_generator/passkey_generator.ino +++ /dev/null @@ -1,70 +0,0 @@ -/* CRC32.ino - * - * This sketch demonstrates how to use the Arduino_CRC32 - * library to calculate a CRC-32 checksum using a simple example of Random passkey suggester. - * - * Abhijeet Kadam - */ - -/************************************************************************************** - * INCLUDE - **************************************************************************************/ - -#include - -/************************************************************************************** - * GLOBAL VARIABLES - **************************************************************************************/ - -Arduino_CRC32 crc32; - -char str1; - -char const ex_msg[] = "My_PassKey"; //your message here - -long randNumber; - -uint32_t crc_code; - -uint32_t final_passkey; - -/************************************************************************************** - * SETUP/LOOP - **************************************************************************************/ - -void setup() -{ - Serial.begin(9600); - - - crc_code = crc32.calc((uint8_t const *)ex_msg, strlen(ex_msg)); // CRC code generation - - Serial.println("Welcome to Random passkey suggester enter y to continue.."); - Serial.println("NOTE: you can change your message in passkey_generator.ino"); - - - -} - -void loop() - { - if (Serial.available() > 0) - { - str1 =Serial.read(); // read the incoming: - - if(str1=='y'||str1=='Y') - { - - Serial.print("Your message : "); - Serial.println(ex_msg); - Serial.print("Your passkey suggestion : "); - - final_passkey = crc_code*random(30,4000)-random(5000); // passkey generation - - Serial.println(final_passkey); - Serial.println("Enter y for new passkey suggestion"); - Serial.println(); - - } - } - }