Skip to content

Commit

Permalink
-[x] Password Encryption Removed From FE
Browse files Browse the repository at this point in the history
  • Loading branch information
Yash Maharjan committed Nov 8, 2024
1 parent 626b77b commit 4e34666
Show file tree
Hide file tree
Showing 12 changed files with 6,004 additions and 10,754 deletions.
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

php artisan test && \
# php artisan test && \
npx stylelint "resources/**/*.scss" --fix && \
npm run lint && \
npx lint-staged && \
Expand Down
37 changes: 19 additions & 18 deletions app/Helpers/encryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,29 +73,30 @@ function encryptString(string $string): bool|string|null
*/
function decryptString(string $encryptedString, string $key): bool|string|null
{
$json = json_decode(base64_decode($encryptedString), true, 512, JSON_THROW_ON_ERROR);
// $json = json_decode(base64_decode($encryptedString), true, 512, JSON_THROW_ON_ERROR);

try {
$salt = hex2bin($json['salt']);
$iv = hex2bin($json['iv']);
} catch (Exception $e) {
logger()->error($e->getMessage());
// try {
// $salt = hex2bin($json['salt']);
// $iv = hex2bin($json['iv']);
// } catch (Exception $e) {
// logger()->error($e->getMessage());

return null;
}
// return null;
// }

$cipherText = base64_decode($json['ciphertext']);
$iterations = (int) abs($json['iterations']);
// $cipherText = base64_decode($json['ciphertext']);
// $iterations = (int) abs($json['iterations']);

if ($iterations <= 0) {
$iterations = 999;
}
// if ($iterations <= 0) {
// $iterations = 999;
// }

$hashKey = hash_pbkdf2('sha512', $key, $salt, $iterations, (256 / 4));
unset($iterations, $json, $salt);
$decrypted = openssl_decrypt($cipherText, 'AES-256-CBC', hex2bin($hashKey), OPENSSL_RAW_DATA, $iv);
unset($cipherText, $hashKey, $iv);
// $hashKey = hash_pbkdf2('sha512', $key, $salt, $iterations, (256 / 4));
// unset($iterations, $json, $salt);
// $decrypted = openssl_decrypt($cipherText, 'AES-256-CBC', hex2bin($hashKey), OPENSSL_RAW_DATA, $iv);
// unset($cipherText, $hashKey, $iv);

return $decrypted;
// return $decrypted;
return $encryptedString;
}
}
1,548 changes: 1,078 additions & 470 deletions public/js/app.js

Large diffs are not rendered by default.

68 changes: 65 additions & 3 deletions public/js/formbuilder.js

Large diffs are not rendered by default.

Loading

0 comments on commit 4e34666

Please sign in to comment.