etcimon / botan

Block & stream ciphers, public key crypto, hashing, KDF, MAC, PKCS, TLS, ASN.1, BER/DER, etc.
Other
86 stars 22 forks source link

DataSource from string #72

Closed GuilhermeStrice closed 7 months ago

GuilhermeStrice commented 7 months ago

I want to load a publickey from a string how do i proceed?

etcimon commented 7 months ago

You can use the following function:

PrivateKey loadKey(DataSource in, RandomNumberGenerator rng, string passphrase = "");

etcimon commented 7 months ago

This example shows how to use DataSource for a string:

https://github.com/etcimon/botan/blob/3387ed99833dcb717bd9f6ab0fad9f0de766f491/source/botan/pubkey/algo/curve25519.d#L308

GuilhermeStrice commented 7 months ago

Thank you so much

GuilhermeStrice commented 7 months ago

Just wanted to say, that.... I didn't think of it before.... You can just pass the string and it compiles. Thanks for the functions

Better documentation would be awesome

GuilhermeStrice commented 7 months ago

Update: it crashes, i guess its by design. Reverting to your solution, doesn't crash and returns something