• Finally had some time to create the modules:

    HMAC
    TOTP

    I will add proper READMEs soon.

    Usage:

    const HMAC = require('https://raw.githubusercontent.com/coajaxial/espruino-hmac/master/hmac.js');
    
    var hmac = HMAC.SHA1(E.toArrayBuffer('my secret key'));
    console.log(hmac.digest(E.toArrayBuffer('my message')));
    
    // FixedSHA1 is faster than SHA1, but digested message must always be the same fixed length.
    var hmacf = HMAC.FixedSHA1(E.toArrayBuffer('my secret key'), 2); // 2 bytes
    console.log(hmacf.digest(E.toArrayBuffer('bb')));
    console.log(hmacf.digest(E.toArrayBuffer('xx')));
    
    const TOTP = require('https://raw.githubusercontent.com/coajaxial/espruino-totp/master/totp.js');
    
    const totp = TOTP.create('JBSWY3DPEHPK3PXP');
    console.log(totp.generate(getTime(), 6, 30));
    
About

Avatar for coajaxial @coajaxial started