Learning More Security
Thursday, April 11, 2024 2:28 PMSecurity
Encryptor
- 대칭 키 암호화 알고리즘인
RIJNDAEL 256
(레인달 256)을 이용하여 정보를 보호할수 있고,BCRYPT HASH
를 이용해 패스워드를 관리할 수 있습니다.
Encrypt
$encrypted = Encryptor::encrypt('value');
Encrypt with salt string
$encrypted = Encryptor::encrypt('value', 'some salt string');
Decrypt
$decrypted = Encryptor::decrypt('value');
Decrypt with salt string
$decrypted = Encryptor::decrypt('value', 'some salt string');
MySQL AES 호환
MySQL의 AES 함수를 구현해 놓았으므로, 암호화를 위해 MySQL에 연결할 필요가 없습니다.
MySQL AES Encrypt
$encrypted = Encryptor::mysqlAesEncrypt('value', 'some encryption key');
MySQL AES Decrypt
$decrypted = Encryptor::mysqlAesDecrypt('value', 'some encryption key');
Password
Hashing
$hash = Password::hash('somepassword');
Verifying
$result = Password::verify('somepassword', $hash);
Re-Hashing
// cost 12
$hash = Password::hash('somepassword', ['cost' => 12]);
// 이후에 cost 가 바뀌거나, hash 알고리즘이 바뀐 경우. (검증은 정상적으로 된다)
if (Password::needsRehash($hash, ['cost' => 20])) {
$hash = Password::hash('somepassword', ['cost' => 20]);
// save...
}