-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: encrypt QR and remove token from QR code (#195)
* feat: encrypt QR and remove token from QR code * test: update integration tests * chore: rename qr-data
- Loading branch information
Showing
9 changed files
with
60 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import * as crypto from "crypto"; | ||
|
||
const algorithm = "aes-256-cbc"; | ||
const key = process.env.CRYPTO_KEY || crypto.randomBytes(32); | ||
const iv = process.env.CRYPTO_IV || crypto.randomBytes(16); | ||
|
||
export function encrypt(text: string) { | ||
const cipher = crypto.createCipheriv(algorithm, key, iv); | ||
let encrypted = cipher.update(text, "utf8", "hex"); | ||
encrypted += cipher.final("hex"); | ||
return encrypted; | ||
} | ||
|
||
export function decrypt(text: string) { | ||
const decipher = crypto.createDecipheriv(algorithm, key, iv); | ||
let decrypted = decipher.update(text, "hex", "utf8"); | ||
decrypted += decipher.final("utf8"); | ||
return decrypted; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
export type QRType = { | ||
access: string; | ||
QRData: string; | ||
group: string; | ||
timestamp: number; | ||
}; |