Skip to content

Instantly share code, notes, and snippets.

View juliancantillo's full-sized avatar
:octocat:

Julian Cantillo juliancantillo

:octocat:
View GitHub Profile
import JsSHA from 'jssha';
export default function getToken(key, period = 30, otp_length = 6) {
let epoch, time, shaObj, hmac, offset, otp;
key = base32tohex(key);
epoch = Math.round(Date.now() / 1000.0);
time = leftpad(dec2hex(Math.floor(epoch / period)), 16, '0');
shaObj = new JsSHA('SHA-1', 'HEX');
shaObj.setHMACKey(key, 'HEX');
shaObj.update(time);
@juliancantillo
juliancantillo / otp.js
Last active September 19, 2019 21:01
A otp library took from internet. https://cdnjs.com/libraries/jsSHA
import JsSHA from 'jssha';
export default function getToken(key, period = 30, otp_length = 6) {
let epoch, time, shaObj, hmac, offset, otp;
key = base32tohex(key);
epoch = Math.round(Date.now() / 1000.0);
time = leftpad(dec2hex(Math.floor(epoch / period)), 16, '0');
shaObj = new JsSHA('SHA-1', 'HEX');
shaObj.setHMACKey(key, 'HEX');
shaObj.update(time);
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Script para geolocalizar direcciones IP y generar tabla LaTeX usando GeoIP2
Uso: python3 geolocalize_ips.py < ips.txt
Requiere: pip install geoip2
Descarga la base de datos GeoLite2-City.mmdb de MaxMind
"""