반응형
# BOOKSWAGE_STATISTICS
 

# DB 설정법
## 1. 저장소 추가
### 커멘드입력
~~~
sudo vi /etc/yum.repos.d/mongodb-org-7.0.repo
~~~
 
### 복사후 저장
~~~
[mongodb-org-7.0]
name=MongoDB Repository
gpgcheck=1
enabled=1
~~~
 
### 커멘드 입력
~~~
sudo yum install -y mongodb-org
~~~


## 2. 몽고 서비스 시작
~~~
sudo systemctl start mongod
~~~

## 3. 몽고 서비스 부팅시 재시작
~~~
sudo systemctl enable mongod
~~~

## 4. 몽고 서비스 상태
~~~
sudo systemctl status mongod
~~~

## 5. 방화벽설정
~~~
sudo firewall-cmd --zone=public --add-port=27017/tcp --permanent
sudo firewall-cmd --reload
~~~
반응형

'SQL' 카테고리의 다른 글

[Postgresql] 데이터베이스 생성  (0) 2023.02.15
반응형

리모트 추가

git remote add origin <URL>

 

리모트 변경

git remote set-url origin

현재 리모트 확인

git remote -v
반응형
반응형

Failed to load env from TypeError: Cannot read properties of undefined (reading 'split')

 

.env 파일내 값이 잘못 됬을때 나는 에러

 

NEXT_PUBLIC_TEST_KEY=1235135$246345345#1231515

'$'는 nextjs에서 예약어라 escape 처리해줘야한다.

'\$' 이런식으로 수정해주면 된다

반응형

'JAVASCRIPT' 카테고리의 다른 글

(javascript) node js 파일 업로드  (0) 2023.02.21
(javascript) 암호화 정리중 ..  (0) 2023.02.20
(js) 파일 업로드 , 다운로드  (0) 2023.01.10
(javascript)상속  (0) 2022.06.27
(javascript)이스케이프 문자열 치환  (0) 2022.05.12
반응형
npm i nodemailer
const nodemailer = require('nodemailer');
const MAIL_CONFIG = require('../config/mail-config.json');

const SendMail = async ({
  title = "",
  from = "",
  to = "",
  description = ""
} = {}) => {
  //sending option
  const transporter = nodemailer.createTransport(MAIL_CONFIG);
  //present option
  const result = await transporter.sendMail({
    from, to,
    subject: title,
    html: MakeTemplete(description)
  });
  return result;
}

 

반응형
반응형
npm i express-fileupload
const fileRoute = express();
const fileUpload = require('express-fileupload');

fileRoute.use(fileUpload({
    createParentPath: true,
    defCharset: 'utf8',
    defParamCharset: 'utf8',
    debug: true
}));


fileRoute.post("/upload", async (req, res, next) => {
    // buffer, encoding, fieldname , mimetype , originalname ,size
   const files = req.files
    const result = await FileUpload(null,files);

files값

{
  name: "원본 파일명.png",
  data: buffer,
  size: 1113653,
  encoding: "7bit",
  tempFilePath: "",
  truncated: false,
  mimetype: "image/png",
}

//or

[{...}, {... }]

 

 

반응형

'JAVASCRIPT' 카테고리의 다른 글

(js) next js 에러  (0) 2023.05.03
(javascript) 암호화 정리중 ..  (0) 2023.02.20
(js) 파일 업로드 , 다운로드  (0) 2023.01.10
(javascript)상속  (0) 2022.06.27
(javascript)이스케이프 문자열 치환  (0) 2022.05.12
반응형

암호화 알고리즘 종류

    type CipherCCMTypes = 'aes-128-ccm' | 'aes-192-ccm' | 'aes-256-ccm' | 'chacha20-poly1305';
    type CipherGCMTypes = 'aes-128-gcm' | 'aes-192-gcm' | 'aes-256-gcm';
    type CipherOCBTypes = 'aes-128-ocb' | 'aes-192-ocb' | 'aes-256-ocb';

 


client-side

Encypt

const CryptoJS = require('crypto-js');

const jsonData = {
    name: 'Alice',
    age: 30
};

// Generate a random key, IV, and salt
const key = CryptoJS.lib.WordArray.random(256/8);
const iv = CryptoJS.lib.WordArray.random(128/8);
const salt = CryptoJS.lib.WordArray.random(128/8);

// Encrypt the JSON data using AES-256-CBC
const encrypted = CryptoJS.AES.encrypt(
    JSON.stringify(jsonData),
    key,
    { iv: iv, salt: salt }
);

// Send the encrypted data and metadata to the server
const dataToSend = {
    data: encrypted.toString(),
    key: key.toString(),
    iv: iv.toString(),
    salt: salt.toString()
};

 


server-side

Decrypt 

const crypto = require('crypto');


async function decryptData(encryptedData, key, iv, salt) {
    try {
        // Decrypt the data using AES-256-CBC
        const decipher = crypto.createDecipheriv('aes-256-cbc', key, iv);
        // decipher.setAuthTag(salt); // Set the authentication tag
        let decryptedData = '';
        decryptedData += decipher.update(encryptedData, 'base64', 'utf8');
        decryptedData += decipher.final('utf8');
        const jsonData = JSON.parse(decryptedData);
        console.log(jsonData); // Output: { name: 'Alice', age: 30 }
    } catch (error) {
        console.error(error);
    }
}

Encrypt

async function encryptData(plaintext, key, iv, salt) {
    try {
      // Derive a key using PBKDF2 with the salt and 100000 iterations
      const derivedKey = await crypto.pbkdf2Sync(key, salt, 100000, 32, 'sha256');

      // Encrypt the data using AES-256-CBC
      const cipher = crypto.createCipheriv('aes-256-cbc', derivedKey, iv);
      let encryptedData = '';
      encryptedData += cipher.update(plaintext, 'utf8', 'base64');
      encryptedData += cipher.final('base64');
      console.log('Encrypted data:', encryptedData);

      // Send the encrypted data and metadata to the client
      const metadata = { key: key.toString('hex'), iv: iv.toString('hex'), salt: salt.toString('hex') };
      console.log('Metadata:', metadata);
    } catch (error) {
      console.error(error);
    }
}
반응형

'JAVASCRIPT' 카테고리의 다른 글

(js) next js 에러  (0) 2023.05.03
(javascript) node js 파일 업로드  (0) 2023.02.21
(js) 파일 업로드 , 다운로드  (0) 2023.01.10
(javascript)상속  (0) 2022.06.27
(javascript)이스케이프 문자열 치환  (0) 2022.05.12
반응형

 

접속

psql -U postgres
sudo -u postgres psql

유저생성

psql -U postgres -c "CREATE USER myuser WITH PASSWORD ‘mypassword’;

권한변경

ALTER ROLE myuser WITH CREATEDB;

ALTER ROLE myuser WITH PASSWORD ;

데이터베이스 생성

CREATE DATABASE my_database OWNER myuser ENCODING 'utf-8';
반응형

'SQL' 카테고리의 다른 글

[centos] 몽고DB 설정법  (1) 2023.10.16
반응형

사전설치

- Android Studio

- Xcode

 

1.  flutter 압축 파일 받은후 아래 경로에 설치

 

2.  PATH 설정

$ open ~/.zprofile
export PATH="$PATH:/Users/dev-nam/development/flutter/bin"

.zprofile 안에 설치된 flutter 경로 bin에 맞춰 PATH를 설정해준다.

 

which flutter

flutter가 정상 작동하는지 확인

 

 

3. Simulator 설정

 open -a Simulator

사용하려는 Simulator를 띄워 놓으면 flutter 실행시 선택할 수 있게 해준다.

 

 

4. 생성

flutter create my_app

 

 

5. 실행

$ cd my_app

 

$ flutter run

 

반응형

+ Recent posts