Re: Symmetric encryption sample code
William Welliver <[email protected]> Tue, 30 Apr 2019 17:09:57 -0400 (EDT)
| Newsgroups | gmane.comp.lang.pike.user |
|---|---|
| Message-ID | <[email protected]> |
Hi Bertrand,
7.6? That's a classic vintage!
Here's some code to get you started... I'm sure that the crypto experts
will be able to provide additional detail.
> object b = Crypto.Buffer(Crypto.AES);
> b->set_encrypt_key("b" * 16); // AES keys may be 128, 192 or 256 bits.
> string e = b->crypt("Mary had a little pike, its scales were smooth and
shiny.");
> e+=b->pad(); // pad out the AES block.
// E contains a binary string. You may wish to encode this (base 64, hex,
etc) for easier transfer
// Decrypt E
> object b = Crypto.Buffer(Crypto.AES);
> b->set_decrypt_key("b" * 16);
> b->unpad(e);
Result: "Mary had a little pike, its scales were smooth and shiny."
On Tue, 30 Apr 2019, Bertrand LUPART - Linkeo.com wrote:
> Hello,
>
>
> Would someone share sample code of symmetric encryption using Pike ? (my target's Pike 7.6)
>
> My goal is to crypt a 20/30 char string using a pre-shared secret and a widespread cipher so that my recipient could decipher it with the technology he'd prefer.
>
> I'm a bit lost in Crypto module reference.
>
>
> Thank you,
>
> --
> Bertrand LUPART