Skip to content

Commit 7755eb5

Browse files
authored
Merge pull request #174 from Sebijk/master
Add MD5(MD5+Salt) and MyBB Hash
2 parents 9ea8261 + 9bd67fc commit 7755eb5

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed

lib/Crypto/MD5MD5Salt.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
/**
3+
* Nextcloud - user_sql
4+
*
5+
* @copyright 2018 Marcin Łojewski <dev@mlojewski.me>
6+
* @author Marcin Łojewski <dev@mlojewski.me>
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Affero General Public License as
10+
* published by the Free Software Foundation, either version 3 of the
11+
* License, or (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU Affero General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Affero General Public License
19+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20+
*/
21+
22+
namespace OCA\UserSQL\Crypto;
23+
24+
/**
25+
* MD5(MD5+salt) hash implementation.
26+
*
27+
* @author Sebijk (b1gMail.eu)
28+
*/
29+
class MD5MD5Salt extends AbstractAlgorithm
30+
{
31+
/**
32+
* @inheritdoc
33+
*/
34+
public function getPasswordHash($password, $salt = null)
35+
{
36+
if (is_null($salt)) {
37+
return false;
38+
}
39+
40+
return md5(md5($password).$salt);
41+
}
42+
43+
/**
44+
* @inheritdoc
45+
*/
46+
protected function getAlgorithmName()
47+
{
48+
return "MD5 (MD5+Salt)";
49+
}
50+
}

lib/Crypto/MyBB.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
/**
3+
* Nextcloud - user_sql
4+
*
5+
* @copyright 2018 Marcin Łojewski <dev@mlojewski.me>
6+
* @author Marcin Łojewski <dev@mlojewski.me>
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Affero General Public License as
10+
* published by the Free Software Foundation, either version 3 of the
11+
* License, or (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU Affero General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Affero General Public License
19+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20+
*/
21+
22+
namespace OCA\UserSQL\Crypto;
23+
24+
/**
25+
* MyBB hash implementation.
26+
*
27+
* @author Sebijk
28+
*/
29+
class MyBB extends AbstractAlgorithm
30+
{
31+
/**
32+
* @inheritdoc
33+
*/
34+
public function getPasswordHash($password, $salt = null)
35+
{
36+
if (is_null($salt)) {
37+
return false;
38+
}
39+
return md5(md5($salt).md5($password));
40+
}
41+
42+
/**
43+
* @inheritdoc
44+
*/
45+
protected function getAlgorithmName()
46+
{
47+
return "MyBB";
48+
}
49+
}

0 commit comments

Comments
 (0)