44 * PHP Encryption API
55 *
66 * @author Raymund John Ang <raymund@open-nis.org>
7- * @version 1.0
7+ * @version 0.9
88 * @license MIT License
99 */
1010
1111// Change 'MySecret12345' to own secret passphrase
12- define ('PASS_PHRASE ' , 'MySecret12345 ' );
12+ define ('PASS_PHRASE ' , 'MySecret12345 ' );
1313
1414/**
1515 * Encrypt data using AES CTR-HMAC
@@ -28,7 +28,7 @@ function encrypt_v1($plaintext)
2828 $ salt = random_bytes (16 ); // Salt (randomness)
2929 $ iv = $ salt ; // Initialization Vector
3030
31- // Derive keys
31+ // Derive Keys
3232 $ masterKey = hash_pbkdf2 ('sha256 ' , PASS_PHRASE , $ salt , 10000 ); // Master Key
3333 $ encKey = hash_hkdf ('sha256 ' , $ masterKey , 32 , 'aes-256-encryption ' , $ salt ); // Encryption Key
3434 $ hmacKey = hash_hkdf ('sha256 ' , $ masterKey , 32 , 'sha-256-authentication ' , $ salt ); // HMAC Key
@@ -67,7 +67,7 @@ function decrypt_v1($encrypted)
6767
6868 $ iv = $ salt ; // Initialization Vector
6969
70- // Derive keys
70+ // Derive Keys
7171 $ masterKey = hash_pbkdf2 ('sha256 ' , PASS_PHRASE , $ salt , 10000 ); // Master Key
7272 $ encKey = hash_hkdf ('sha256 ' , $ masterKey , 32 , 'aes-256-encryption ' , $ salt ); // Encryption Key
7373 $ hmacKey = hash_hkdf ('sha256 ' , $ masterKey , 32 , 'sha-256-authentication ' , $ salt ); // HMAC Key
0 commit comments