[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Let us see how to encrypt with Emacs?
From: |
Jean Louis |
Subject: |
Re: Let us see how to encrypt with Emacs? |
Date: |
Fri, 9 Jul 2021 14:32:10 +0300 |
User-agent: |
Mutt/2.0.7+183 (3d24855) (2021-05-28) |
* Eli Zaretskii <eliz@gnu.org> [2021-07-09 13:40]:
> > (setq encrypted (gnutls-symmetric-encrypt "CHACHA20-64" (string-pad
> > "MyPassword987" 32) (make-string 16 (random 100)) (string-pad "Text to
> > encrypt" 64)))
> >
> > And I can decrypt it:
> >
> > (car (gnutls-symmetric-decrypt "CHACHA20-64" (string-pad "MyPassword987"
> > 32) (cadr encrypted) (car encrypted))) ⇒ "Text to encrypt
> > "
> >
> > but that is not well integrated for practical encryption as I
> > have to employ padding even for string to be encrypted, and
> > chunking of string to 64 bytes.
>
> No, you don't need to chunk, you just need to pad to a multiple of 64
> bytes.
I guess something like this unless I am making an error:
(defun pad-to-multiple-bytes (string max)
"Return string padded to multiple of MAX bytes."
(let* ((bytes (string-bytes string))
(multiple (truncate (/ bytes max)))
(multiple (if (zerop multiple) max (* (1+ multiple) max))))
(string-pad string multiple)))
> What kind of help? To use these functions, you need to learn about
> the various ciphers and what they require. This is something the
> Emacs Lisp reference manual cannot teach you.
>
> > ‘STRING’
> > A string as input will be used directly. It may be modified by the
> > function (unlike most other Emacs Lisp functions) to reduce the
> > chance of exposing sensitive data after the function does its work.
> >
> > I am trying to use list with STRING as following and that does not work:
> >
> > (gnutls-symmetric-encrypt "CHACHA20-64" (string-pad "MyPassword987" 32)
> > (make-string 16 (random 100)) '(STRING "Text to encrypt"))
>
> What do you mean by "does not work"?
I get invalid object argument: STRING so I do not understand how to use STRING
there.
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
Re: Let us see how to encrypt with Emacs?, Jean Louis, 2021/07/09