Richard Schmidt
11 months ago
5 changed files with 101 additions and 129 deletions
-
41src/main/java/CreateUser.java
-
43src/main/java/LoginGUI.java
-
21src/main/java/PasswordHasher.java
-
87src/main/java/SignUpGUI.java
-
38user.json
@ -0,0 +1,21 @@ |
|||||
|
import java.security.MessageDigest; |
||||
|
import java.security.NoSuchAlgorithmException; |
||||
|
|
||||
|
public class PasswordHasher { |
||||
|
public static String hashPassword(String password) { |
||||
|
try { |
||||
|
MessageDigest digest = MessageDigest.getInstance("SHA-256"); |
||||
|
byte[] hash = digest.digest(password.getBytes()); |
||||
|
StringBuilder hexString = new StringBuilder(); |
||||
|
for (byte b : hash) { |
||||
|
String hex = Integer.toHexString(0xff & b); |
||||
|
if (hex.length() == 1) hexString.append('0'); |
||||
|
hexString.append(hex); |
||||
|
} |
||||
|
return hexString.toString(); |
||||
|
} catch (NoSuchAlgorithmException e) { |
||||
|
e.printStackTrace(); |
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
|
} |
@ -1,47 +1,11 @@ |
|||||
[ |
[ |
||||
{ |
{ |
||||
"id": "d7ae19fe-4684-4d69-a73d-4cca612962a3", |
|
||||
|
"id": "c99b1061-13b7-4fa8-b1ac-814e07db3ef4", |
||||
"userName": "Test", |
"userName": "Test", |
||||
"password": "8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92", |
"password": "8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92", |
||||
"birthday": "", |
"birthday": "", |
||||
"firstName": "", |
"firstName": "", |
||||
"surname": "", |
"surname": "", |
||||
"stayLoggedIn": false |
"stayLoggedIn": false |
||||
}, |
|
||||
{ |
|
||||
"id": "2ec2c0c5-677c-4262-8958-fef98d11cc63", |
|
||||
"userName": "Test2", |
|
||||
"password": "8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92", |
|
||||
"birthday": "", |
|
||||
"firstName": "", |
|
||||
"surname": "", |
|
||||
"stayLoggedIn": false |
|
||||
}, |
|
||||
{ |
|
||||
"id": "ccfcc294-48ad-49db-996f-d7c99a93bac9", |
|
||||
"userName": "testuser", |
|
||||
"password": "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8", |
|
||||
"birthday": "2000-01-01", |
|
||||
"firstName": "John", |
|
||||
"surname": "Doe", |
|
||||
"stayLoggedIn": false |
|
||||
}, |
|
||||
{ |
|
||||
"id": "27ffc70f-dd76-4765-81e3-76fde9b618e5", |
|
||||
"userName": "testUser", |
|
||||
"password": "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8", |
|
||||
"birthday": "1990-01-01", |
|
||||
"firstName": "John", |
|
||||
"surname": "Doe", |
|
||||
"stayLoggedIn": false |
|
||||
}, |
|
||||
{ |
|
||||
"id": "731fda82-6b51-4f3f-ae97-c9b01c9b4a1a", |
|
||||
"userName": "existinguser", |
|
||||
"password": "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8", |
|
||||
"birthday": "1990-01-01", |
|
||||
"firstName": "John", |
|
||||
"surname": "Doe", |
|
||||
"stayLoggedIn": false |
|
||||
} |
} |
||||
] |
] |
Write
Preview
Loading…
Cancel
Save
Reference in new issue