Skip to content

Instantly share code, notes, and snippets.

@voidmain
voidmain / ReactiveHasher.java
Created March 12, 2019 22:24
Reactive password hashing based on password length
PasswordHasher hasher;
if (password.length() >= 14) {
hasher = new SHA512PasswordHasher();
} else {
hasher = new BCryptPasswordHasher();
}
String hashedPassword = hasher.hash(password);
@voidmain
voidmain / PasswordCrack.java
Created March 12, 2019 22:18
Java password cracker
import org.apache.commons.codec.digest.DigestUtils;
public class PasswordCrack {
public static final char[] PASSWORD_CHARACTERS = new char[] {'a', 'b', 'c', 'd'};
public static void main(String... args) {
String salt = args[0];
String hashFromDatabase = args[1].toUpperCase();
for (int i = 6; i <= 8; i++) {
@voidmain
voidmain / SaltExample.kt
Last active March 12, 2019 22:28
Salting and SHAing passwords
// Bad, no salt. Very bland.
sha2("password") // 6b3a55e0261b0304143f805a24924d0c1c44524821305f31d9277843b8a10f4e
// Better, add a salt.
salt = ";L'-2!;+=#/5B)40/o-okOw8//3a"
toHash = ";L'-2!;+=#/5B)40/o-okOw8//3apassword"
sha2(toHash) // f534e6bf84a638112e07e69861927ab624c0217c0655e4d3be07659bcf6c1c07
@voidmain
voidmain / sha-lookup-table.txt
Last active March 12, 2019 22:29
SHA2 password lookup table
sha2_hash password
-----------------------------------------------------------------------------------------
e150a1ec81e8e93e1eae2c3a77e66ec6dbd6a3b460f89c1d08aecf422ee401a0 123456
e5d316bfd85b606e728017e9b6532e400f5f03e49a61bc9ef59ec2233e41015a broncosfan123
561acac680e997e22634a224df2c0931cf80b9f7c60102a4e12e059f87558232 Letmein
bdc511ea9b88c90b75c3ebeeb990e4e7c813ee0d5716ab0431aa94e9d2b018d6 newenglandclamchowder
9515e65f46cb737cd8c191db2fd80bbd05686e5992b241e8ad7727510b7142e6 opensesame
6b3a55e0261b0304143f805a24924d0c1c44524821305f31d9277843b8a10f4e password
c194ead20ad91d30c927a34e8c800cb9a13a7e445a3ffc77fed14176edc3c08f xboxjunkie42

Keybase proof

I hereby claim:

  • I am voidmain on github.
  • I am voidmain (https://keybase.io/voidmain) on keybase.
  • I have a public key whose fingerprint is 4A71 27D9 FA32 A16F 3BFF FB7B 52F6 C1EC 9653 CE82

To claim this, I am signing this object:

@voidmain
voidmain / passport-client-snippet.csharp
Last active May 24, 2016 23:16 — forked from robotdan/passport-client-snippet.csharp
PassportClient Code Snippets
/* Authenticate a User */
Guid applicationId = new Guid("00000000-0000-0000-0000-00000000002a");
LoginRequest request = new LoginRequest(applicationId, "bob@example.com", null, "secret");
ClientResponse<LoginResponse, Errors> response = client.Login(request, null);
User user = response.successResponse.user;
/* Retrieve User by Email Address */
ClientResponse<UserResponse, Errors> response = client.RetrieveUserByEmail("bob@example.com");
User user = response.successResponse.user;