PKI Digital Signature Examples
Andrew Lambert edited this page Jan 21, 2023
·
10 revisions
libsodium offers facilities to sign and verify data using the private key of one user and the public key of the other; nothing secret needs to be exchanged.
Dim key As libsodium.PKI.SigningKey
key = key.Generate()
Use the same seed to generate the same key
Dim key As libsodium.PKI.SigningKey
key = key.Generate(key.RandomSeed)
Use the same password, salt, and resource limits to generate the same key
Dim passwd As New libsodium.Password("seekritpassword")
Dim key As New libsodium.PKI.SigningKey(passwd, passwd.RandomSalt, libsodium.ResourceLimits.Interactive)
Dim mykey As libsodium.PKI.SigningKey
mykey = mykey.Generate() ' random key for example
Dim SignedData As MemoryBlock = libsodium.PKI.SignData("Hello, world!", mykey)
Dim theirkey As New libsodium.PKI.PublicKey(libsodium.PKI.SigningKey.Generate) ' random for example
Dim SignedData As MemoryBlock ' the signed message, assume valid for example
Dim Data As MemoryBlock = libsodium.PKI.VerifyData(SignedData, theirkey)
Wiki home | Project page | Bugs
Text and code examples are Copyright ©2016-23 Andrew Lambert, offered under the CC BY-SA 3.0 License.