Move the secure-random code into this project due to build issues with the module, which is no longer maintained
This commit is contained in:
parent
2c73703d7d
commit
a56cae626a
12 changed files with 110 additions and 18 deletions
|
|
@ -0,0 +1,28 @@
|
|||
package xyz.blueskyweb.pubsq;
|
||||
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||
import com.facebook.react.bridge.ReactMethod;
|
||||
import com.facebook.react.bridge.Promise;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
import android.util.Base64;
|
||||
|
||||
public class AppSecureRandomModule extends ReactContextBaseJavaModule {
|
||||
public AppSecureRandomModule(ReactApplicationContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void generateSecureRandomAsBase64(int length, Promise promise) {
|
||||
SecureRandom secureRandom = new SecureRandom();
|
||||
byte[] buffer = new byte[length];
|
||||
secureRandom.nextBytes(buffer);
|
||||
promise.resolve(Base64.encodeToString(buffer, Base64.NO_WRAP));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "AppSecureRandomModule";
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue