This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Promise = require('bluebird'); | |
var crypto = Promise.promisifyAll(require("crypto")); | |
// http://security.stackexchange.com/questions/110084/parameters-for-pbkdf2-for-password-hashing | |
var config = { | |
hashBytes : 64, // size of the generated hash (to be chosen accordint the the chosen algo) | |
saltBytes : 16, // sise of the salt : larger salt means hashed passwords are more resistant to rainbow table | |
iterations : 500000, // tune so that hashing the password takes about 1 second | |
algo :'sha512', | |
encoding : 'base64' // hex is readable but base64 is shorter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def enumerate_serial_ports(): | |
""" | |
Purpose: scan for available ports | |
Return: return a list containing the names of | |
the availables serial ports | |
""" | |
outAvailablePorts = [] | |
for i in range(256): | |
try: | |
s = serial.Serial(i) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################# Compute CRC16 from buffer ############### | |
""" usage: add : from crc16 import crc16 | |
call crc16(vCRCList) | |
""" | |
def crc16(packet): | |
POLY = 0x8408 # 0x8408 is deduced from the polynomial X**16 + X**12 + X**5 + X**0 | |
# process each byte | |
vFCS = 0xFFFF; # init FCS to all ones |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import serial | |
import random, time, math | |
ser = serial.Serial(0, 38400) | |
incycle = 0 | |
while True: | |
t = int(random.randint(60, 80) * (1 + math.sin(incycle))) | |
print "sent data:", t |