-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
๐ Merge pull request #136 from qkrwogk/feat/board-security
[BE] Board๋ชจ๋ ๋ณด์ : ๊ฒ์๊ธ ๋ณธ๋ฌธ ์๋ณตํธํ,Entity ๊ด๊ณ์ ์ฉ, AuthGuard ์ ์ฉ, ๊ฒ์๊ธ ์์ฑ ์ author ์๋ฒ๊ฐ ์ฝ์
- Loading branch information
Showing
14 changed files
with
116 additions
and
16 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
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
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
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,8 @@ | ||
import { configDotenv } from 'dotenv'; | ||
configDotenv(); | ||
|
||
export const aesConfig = { | ||
password: process.env.AES_PASSWORD, | ||
salt: process.env.AES_SALT, | ||
iv: Buffer.alloc(16, 0), | ||
}; |
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,26 @@ | ||
import * as crypto from 'crypto'; | ||
import { aesConfig } from '../config/aes.config'; | ||
|
||
const encryptAes = (plainText) => { | ||
const algorithm = 'aes-256-cbc'; // ์ํธ ์๊ณ ๋ฆฌ์ฆ | ||
const key = crypto.scryptSync(aesConfig.password, aesConfig.salt, 32); // ์ํธํ ํค | ||
const iv = aesConfig.iv; // ์ด๊ธฐํ ๋ฒกํฐ | ||
|
||
const cipher = crypto.createCipheriv(algorithm, key, iv); | ||
let cipherText = cipher.update(plainText, 'utf8', 'base64'); | ||
cipherText += cipher.final('base64'); | ||
return cipherText; | ||
}; | ||
|
||
const decryptAes = (cipherText) => { | ||
const algorithm = 'aes-256-cbc'; // ์ํธ ์๊ณ ๋ฆฌ์ฆ | ||
const key = crypto.scryptSync(aesConfig.password, aesConfig.salt, 32); // ์ํธํ ํค | ||
const iv = aesConfig.iv; // ์ด๊ธฐํ ๋ฒกํฐ | ||
|
||
const decipher = crypto.createDecipheriv(algorithm, key, iv); | ||
let plainText = decipher.update(cipherText, 'base64', 'utf8'); | ||
plainText += decipher.final('utf8'); | ||
return plainText; | ||
}; | ||
|
||
export { encryptAes, decryptAes }; |
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