Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Michael Telatynski
Olm
Commits
700b0258
Commit
700b0258
authored
Oct 21, 2016
by
pedroGitt
Browse files
Add getRandomKey()
parent
fb87d8fe
Changes
1
Hide whitespace changes
Inline
Side-by-side
java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmUtility.java
View file @
700b0258
...
...
@@ -20,10 +20,14 @@ import android.text.TextUtils;
import
android.util.Log
;
import
java.io.Serializable
;
import
java.util.Random
;
public
class
OlmUtility
implements
Serializable
{
public
class
OlmUtility
{
private
static
final
String
LOG_TAG
=
"OlmUtility"
;
public
static
final
int
RANDOM_KEY_SIZE
=
32
;
public
static
final
int
RANDOM_RANGE
=
256
;
/** raw pointer value returned by JNI.
* this value uniquely identifies this utility instance.
**/
...
...
@@ -128,9 +132,17 @@ public class OlmUtility implements Serializable {
private
native
String
sha256Jni
(
String
aMessage
);
// TODO missing API: initWithSerializedData
// TODO missing API: serializeDataWithKey
// TODO missing API: initWithCoder
// TODO missing API: encodeWithCoder
public
static
String
getRandomKey
()
{
String
keyRetValue
;
Random
rand
=
new
Random
();
StringBuilder
strBuilder
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
RANDOM_KEY_SIZE
;
i
++)
{
strBuilder
.
append
(
rand
.
nextInt
(
RANDOM_RANGE
));
}
keyRetValue
=
strBuilder
.
toString
();
return
keyRetValue
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment