Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/main/java/org/libsodium/jni/crypto/Hash.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,18 @@ public byte[] sha512(byte[] message) {
}

public String sha256(String message, Encoder encoder) {
byte[] hash = sha256(message.getBytes());
byte[] hash = sha256(encoder.decode( message ));
return encoder.encode(hash);
}

public String sha512(String message, Encoder encoder) {
byte[] hash = sha512(message.getBytes());
byte[] hash = sha512(encoder.decode( message ));
return encoder.encode(hash);
}

public String pwhash_scryptsalsa208sha256(String passwd, Encoder encoder, byte[] salt, int opslimit, int memlimit) {
buffer = new byte[KEY_LEN];
//sodium().crypto_pwhash(buffer, buffer.length, passwd.getBytes(), passwd.length(), salt, opslimit, memlimit,sodium().crypto_pwhash_alg_default());

sodium().crypto_pwhash_scryptsalsa208sha256(buffer, buffer.length, passwd.getBytes(), passwd.length(), salt, opslimit, memlimit);
sodium().crypto_pwhash_scryptsalsa208sha256(buffer, buffer.length, encoder.decode( passwd ), passwd.length(), salt, opslimit, memlimit);
return encoder.encode(buffer);
}

Expand All @@ -66,7 +64,7 @@ public byte[] blake2(byte[] message) throws UnsupportedOperationException {

public String blake2(String message, Encoder encoder) throws UnsupportedOperationException {
if (!blakeSupportedVersion()) throw new UnsupportedOperationException();
byte[] hash = blake2(message.getBytes());
byte[] hash = blake2(encoder.decode( message ));
return encoder.encode(hash);
}

Expand Down