Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createRandomId, createHashedId 구현 #23

Merged
merged 8 commits into from
Feb 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: add createRandomId
Hanna922 committed Feb 9, 2024
commit c77d3a752988ad81033f76fad0cd649bf49f5a2b
14 changes: 14 additions & 0 deletions src/Logger.ts
Original file line number Diff line number Diff line change
@@ -7,6 +7,20 @@ const createHashedId = (userId: string) => {
return hashedId;
};

const createRandomId = () => {
let result = '';
const charactersRange = { start: 33, end: 126 };

for (let i = 0; i < 10; i++) {
const randomCharCode =
Math.floor(Math.random() * (charactersRange.end - charactersRange.start + 1)) +
charactersRange.start;
result += String.fromCharCode(randomCharCode);
}

return result;
};

const createTimestamp = () => {
const offset = new Date().getTimezoneOffset() * 60 * 1000;
const now = new Date(Date.now() - offset);