A Pen by Patrick Favre-Bulle on CodePen.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Binary | |
┌─────────────────┬──────────────────────────────────────────────────────────────────┐ | |
│ Efficiency │ 12.5 % (1 bit/char), 1 bit segments │ | |
│ 32/64/128 bit │ 1-32/1-64/1-128 chars │ | |
│ Padding │ false │ | |
│ Const. Out. Len.│ false │ | |
│ Suited for │ number encoding, debugging │ | |
│ Alphabet │ 01 │ | |
│ Known Usages │ none │ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright 2017 Patrick Favre-Bulle | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Copyright 2017 Patrick Favre-Bulle | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import at.favre.lib.bytes.Bytes; | |
import org.openjdk.jmh.annotations.*; | |
import org.openjdk.jmh.infra.Blackhole; | |
import java.util.concurrent.TimeUnit; | |
@SuppressWarnings("CheckStyle") | |
@State(Scope.Thread) | |
@Fork(1) | |
@Warmup(iterations = 2, time = 4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
byte[] key = Bytes.random(16).array(); | |
long id = ... | |
IdMask<Long> idMask = IdMasks.forLongIds(Config.builder(key).build()); | |
String maskedId = idMask.mask(id); | |
//example: NPSBolhMyabUBdTyanrbqT8 | |
long originalId = idMask.unmask(maskedId); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package your.app; | |
/* | |
* Copyright (c) 2001 - 2012 Sileria, Inc. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.Random; | |
public class Tester { | |
public static String[] pws = {"ZeDRJ:_tu:", "ZeDRJ:_tu1", "ZeDRJ:_tu2", "ZeDRJ:_tu3", "ZeDRJ:_tu4", "ZeD1", "ZeDRJu1", "ZeDRJ:_tu19881", "98asfhj", "adasd", "()=H)d"}; | |
public static Random r = new Random(); | |
public static List<BCrypt.Verifyer> verifyers = new ArrayList<>(); | |
public static boolean introduceMemoryLeak = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright 2017 Patrick Favre-Bulle | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |