https://github.com/thomaschaplin/image-to-totp
🔐 Convert QR images to TOTP codes
https://github.com/thomaschaplin/image-to-totp
2fa 2fa-codes 2factor qrcode totp
Last synced: 15 days ago
JSON representation
🔐 Convert QR images to TOTP codes
- Host: GitHub
- URL: https://github.com/thomaschaplin/image-to-totp
- Owner: thomaschaplin
- License: mit
- Created: 2020-11-03T12:41:12.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-07-19T00:14:44.000Z (almost 2 years ago)
- Last Synced: 2025-04-09T15:44:36.051Z (25 days ago)
- Topics: 2fa, 2fa-codes, 2factor, qrcode, totp
- Language: TypeScript
- Homepage:
- Size: 812 KB
- Stars: 10
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# image-to-totp



image-to-totp is a library to generate totp codes from a QR code image with a single API.
## Usage
```
npm install @thomaschaplin/image-to-totp
```### Example Usage
Find full example [here](https://github.com/thomaschaplin/image-to-totp/blob/master/examples/src/image-to-totp.ts) but see the below code snippet
```
src/
images/
example1.png
example2.png
``````ts
import { imageToTotp } from "@thomaschaplin/image-to-totp";
import * as path from "path";const example = async (account: string) => {
const projectBaseFolder = path.join(__dirname, "../");
const imagesFolder = path.join(projectBaseFolder, "src/images");
const totp = await imageToTotp(`${imagesFolder}/${account}.png`);
console.log(`Account: ${account} - ${totp}`);
};example("example1"); // Account: example1 - 034624
example("example2"); // Account: example2 - 084841
```## Description
This repository allows you to take a QR code image and turn it into a TOTP code.
This project uses:
- [jimp](https://github.com/oliver-moran/jimp)
- [jsqr](https://github.com/cozmo/jsQR)
- [otpauth](https://github.com/hectorm/otpauth)## Setup
Make sure you have [Node.js](https://nodejs.org/en/) installed on your machine
### Development
#### Installation
- Clone this repository
`git clone [email protected]:thomaschaplin/image-to-totp.git`
- Change directory `cd image-to-totp`
- Install the dependencies `npm install`
- Transpile the code `npm run build` or `npm run watch`#### Tests
- Run the tests `npm test`
- Run the tests with coverage `npm run test:coverage`
- Run the tests with mutation testing `npm run test:mutation`---
Image by
mohamed
Hassan from
Pixabay