Python Flask 암호화 및 JWT 사용

2020. 9. 20. 19:51서버 프로그래밍

Node.js가 이건 확실하게 편했던것 같다.

import hashlib
dk = hashlib.pbkdf2_hmac('sha256', b'password', b'salt', 100000)
dk.hex()
'0394a2ede332c9a13eb82e9b24631604c31df978b4e2f0fbd2c549944f9d79a5'

docs.python.org/3/library/hashlib.html

 

hashlib — Secure hashes and message digests — Python 3.8.6rc1 documentation

hashlib — Secure hashes and message digests Source code: Lib/hashlib.py This module implements a common interface to many different secure hash and message digest algorithms. Included are the FIPS secure hash algorithms SHA1, SHA224, SHA256, SHA384, and

docs.python.org

# only an example, you can choose a different encoding
bytes('example', encoding='utf-8')

stackoverflow.com/questions/19511440/add-b-prefix-to-python-variable/19511539

 

Add "b" prefix to python variable?

Adding the prefix "b" to a string converts it to bytes: b'example' But I can't figure out how to do this with a variable. Assuming string = 'example', none of these seem to work: b(string) b str...

stackoverflow.com

 

로그인 토큰은 JWT로 돌려줘야 제맛.

justkode.kr/python/flask-restapi-3

 

Flask로 REST API 구현하기 - 3. JWT로 사용자 인증하기

REST API를 사용 하게 된다면, 사용자 인증 방법으로 제일 많이 사용하는 것이 JWT (JSON Web Token) 입니다. JWT에 대해 더 알고 싶다면. Velopert 님의 게시글을 참고 해 주세요! 우선 설치해야 할 것 일단 b

justkode.kr

 

덤으로 간만에 MySQL 세팅하며 utf8_general_ci Collation에 대해서 참고한 레퍼런스

bestugi.tistory.com/16

 

MySQL의 캐릭터셋 인코딩 이해하기

Database가 문자와 관련된 데이터 타입이 주를 이루기 때문에 캐릭터셋 인코딩에 대해서는 꼭 짚고 넘어가야한다. 본인도 문제가 발생할 때마다 검색을 통한 해당 문제 해결에 집중하였던 터라, ��

bestugi.tistory.com