1
0
forked from Yara724/api

Initial commit after migration to gitea

This commit is contained in:
2026-01-18 11:27:43 +03:30
parent a21039410c
commit ea4b8eb543
196 changed files with 45567 additions and 9 deletions

View File

@@ -0,0 +1,16 @@
import { Injectable } from "@nestjs/common";
// import crypto from "crypto"
const crypto = require("node:crypto");
@Injectable()
export class OtpService {
createDigit(digits: number): string {
const max = Math.pow(10, digits);
const randomBytes = crypto.randomBytes(Math.ceil(digits / 2));
const randomNumber = parseInt(randomBytes.toString("hex"), 16) % max;
return randomNumber.toString().padStart(digits, "0");
}
create() {
return this.createDigit(5);
}
}