From 13b4572a2f58231272c7f40add706d561ecf4855 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 7 Mar 2022 18:12:43 +0100 Subject: limit password length to 10000 characters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit that should be sufficient… --- lib/Travelynx.pm | 2 +- lib/Travelynx/Controller/Account.pm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index 49c1399..eec16ca 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -36,7 +36,7 @@ use XML::LibXML; sub check_password { my ( $password, $hash ) = @_; - if ( bcrypt( $password, $hash ) eq $hash ) { + if ( bcrypt( substr( $password, 0, 10000 ), $hash ) eq $hash ) { return 1; } return 0; diff --git a/lib/Travelynx/Controller/Account.pm b/lib/Travelynx/Controller/Account.pm index 0435d51..97ea8ad 100644 --- a/lib/Travelynx/Controller/Account.pm +++ b/lib/Travelynx/Controller/Account.pm @@ -13,7 +13,7 @@ sub hash_password { my @salt_bytes = map { int( rand(255) ) + 1 } ( 1 .. 16 ); my $salt = en_base64( pack( 'C[16]', @salt_bytes ) ); - return bcrypt( $password, '$2a$12$' . $salt ); + return bcrypt( substr( $password, 0, 10000 ), '$2a$12$' . $salt ); } sub make_token { -- cgit v1.2.3