all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jean Louis <bugs@gnu.support>
To: tomas@tuxteam.de
Cc: help-gnu-emacs@gnu.org
Subject: Re: Let us see how to encrypt with Emacs?
Date: Fri, 9 Jul 2021 15:35:21 +0300	[thread overview]
Message-ID: <YOhCibYJxLUk/ZFP@protected.localdomain> (raw)
In-Reply-To: <20210709115239.GB3074@tuxteam.de>

* tomas@tuxteam.de <tomas@tuxteam.de> [2021-07-09 14:53]:
> On Fri, Jul 09, 2021 at 02:32:10PM +0300, Jean Louis wrote:
> > * Eli Zaretskii <eliz@gnu.org> [2021-07-09 13:40]:
> 
> [...]
> 
> > > 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)))
> 
> small critiques
> 
>  - see the `ceiling' function: it does what you want (perhaps
>    except at zero.

Thanks, now I know for that:

(defun pad-to-multiple-bytes (string length)
  "Return string padded to multiple of MAX bytes."
  (let* ((bytes (string-bytes string))
	 (multiple (* (ceiling bytes length) length)))
    (string-pad string multiple)))

> I'm not sure you want to encrypt a zero bytes string at all, but
> this might get philosophical)

There may be problems which I will never encounter practically. I know.

>  MAX is an unfortunate variable name for that.

Now is length.

-- 
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 12:35 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
2021-07-09 11:52     ` tomas
2021-07-09 12:35       ` Jean Louis [this message]
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

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

  git send-email \
    --in-reply-to=YOhCibYJxLUk/ZFP@protected.localdomain \
    --to=bugs@gnu.support \
    --cc=help-gnu-emacs@gnu.org \
    --cc=tomas@tuxteam.de \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.