unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Eli Zaretskii <eliz@gnu.org>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Let us see how to encrypt with Emacs?
Date: Fri, 9 Jul 2021 14:32:10 +0300	[thread overview]
Message-ID: <YOgzunqpaoYHLdoA@protected.localdomain> (raw)
In-Reply-To: <83mtqvdb4s.fsf@gnu.org>

* 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/



  reply	other threads:[~2021-07-09 11:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-09  7:38 Let us see how to encrypt with Emacs? Jean Louis
2021-07-09 10:39 ` Eli Zaretskii
2021-07-09 11:32   ` Jean Louis [this message]
2021-07-09 11:52     ` tomas
2021-07-09 12:35       ` Jean Louis
2021-07-09 12:43         ` tomas
2021-07-09 11:55     ` Eli Zaretskii
2021-07-09 12:28       ` Jean Louis
2021-07-09 12:53         ` Eli Zaretskii
2021-07-09 12:27   ` Jean Louis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YOgzunqpaoYHLdoA@protected.localdomain \
    --to=bugs@gnu.support \
    --cc=eliz@gnu.org \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).