Skip to content
This repository has been archived by the owner on Aug 8, 2019. It is now read-only.

Commit

Permalink
changed base64 checker
Browse files Browse the repository at this point in the history
  • Loading branch information
frumbert committed Mar 21, 2017
1 parent 777a2b6 commit 5ec6637
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion login.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,18 @@
function wp2m_base64_decode($b64) {
return base64_decode(str_replace(array('-','_'),array('+','/'),$b64));
}
function wp2m_is_base64($string) {
$decoded = base64_decode($string, true);
// Check if there is no invalid character in string
if (!preg_match('/^[a-zA-Z0-9\/\r\n+]*={0,2}$/', $string)) return false;
// Decode the string in strict mode and send the response
if (!base64_decode($string, true)) return false;
// Encode and compare it to original one
if (base64_encode($decoded) != $string) return false;
return true;
}
function decrypt_string($data, $key) {
if ( base64_encode(base64_decode($key)) === $key){
if ( wp2m_is_base64($key)) {
$encryption_key = base64_decode($key);
} else {
$encryption_key = $key;
Expand Down

0 comments on commit 5ec6637

Please sign in to comment.