File tree Expand file tree Collapse file tree
demo/src/commonMain/kotlin/com/wannaverse/crypto Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ import androidx.compose.ui.Modifier
1010import androidx.compose.ui.unit.dp
1111import com.wannaverse.crypto.core.Encoding.fromHex
1212import com.wannaverse.crypto.core.Encoding.toHex
13+ import com.wannaverse.crypto.hashing.Argon2
14+ import com.wannaverse.crypto.hashing.Argon2Config
15+ import com.wannaverse.crypto.hashing.Argon2Type
1316import com.wannaverse.crypto.hashing.sha1
1417import org.jetbrains.compose.ui.tooling.preview.Preview
1518
@@ -30,10 +33,25 @@ fun App() {
3033 val fromHex = fromHex(toHex)
3134 val isEqual = hashed.contentEquals(fromHex)
3235
33- Text (" " + hashed)
34- Text (" " + toHex)
35- Text (" " + fromHex)
36- Text (" " + isEqual)
36+ Text (" SHA1: $toHex " )
37+ Text (" Hex roundtrip: $isEqual " )
38+
39+ // Argon2 password hashing example
40+ val password = " mypassword" .encodeToByteArray()
41+ val salt = " somesalt12345678" .encodeToByteArray()
42+ val argon2 = Argon2 ()
43+ val argon2Hash = argon2.hash(
44+ password = password,
45+ salt = salt,
46+ config = Argon2Config (
47+ type = Argon2Type .Argon2id ,
48+ hashLength = 16 ,
49+ parallelism = 1 ,
50+ memorySizeKB = 16 ,
51+ iterations = 3 ,
52+ )
53+ )
54+ Text (" Argon2id: ${toHex(argon2Hash)} " )
3755
3856 }
3957 }
You can’t perform that action at this time.
0 commit comments