[php] openssl encrypt/decrypt(AES-256-ECB)
function encrypt($plaintext, $password) { $method = "AES-256-ECB"; $key = hash('sha256', $password, true); $encrypt_iv = openssl_random_pseudo_bytes(16); $ciphertext = openssl_encrypt($plaintext, $method, $key, OPENSSL_RAW_DATA, $encrypt_iv); $hash = hash_hmac('sha256', $ciphertext . $encrypt_iv, $key, true); return $encrypt_iv . $hash . $ciphertext; } function decrypt($ivHashCiphertext, $passwo..
2022. 8. 9.
[MySQL] MySQL 공백, 탭, 라인피드, 캐리지리턴 등을 제거하는 방법
MySQL 공백, 탭, 라인피드, 캐리지리턴 등을 제거하는 방법 필드값 변경 함수 replace(필드명, 변경할 문자, 변경될 문자) - '필드명'에 해당하는 레코드에서 '변경할 문자'를 모두 '변경될 문자'로 변경한다. 1. 공백제거(앞/뒤의 공백을 제거한다) - update table set field = replace(field, ' ', ''); * table은 테이블명, field는 필드명이다. 2. 개행문자 제거 - update table set field = replace(field, '\r\n', ''); 3. 탭( Tab - char(9) ) 제거 - update table set field = replace(field, char(9), ''); - field 값에 탭(char(9))이 ..
2021. 2. 24.