help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Let us see how to encrypt with Emacs?


From: Eli Zaretskii
Subject: Re: Let us see how to encrypt with Emacs?
Date: Fri, 09 Jul 2021 13:39:31 +0300

> Date: Fri, 09 Jul 2021 10:38:41 +0300
> From: Jean Louis <bugs@gnu.support>
> 
> (gnutls-symmetric-encrypt "CHACHA20-64" "MyPassword987" (make-string 16 
> (random 100)) "Text to encrypt")
> 
> but error is:
> 
> (error "GnuTLS cipher CHACHA20-64/encrypt key length 13 is not equal to the 
> required 32")
> 
> which is somehow clear, so maybe I could use the function `string-pad':
> 
> (gnutls-symmetric-encrypt "CHACHA20-64" (string-pad "MyPassword987" 32) 
> (make-string 16 (random 100)) "Text to encrypt")
> 
> then I get error:
> 
> (error "GnuTLS cipher CHACHA20-64/encrypt input block length 15 is not a 
> multiple of the required 64")
> 
> and try to remedy it with some result, that is vague, as text
> longer than 64 I would not know how to chunk and what is expected
> from me:
> 
> (gnutls-symmetric-encrypt "CHACHA20-64" (string-pad "MyPassword987" 32) 
> (make-string 16 (random 100)) (string-pad "Text to encrypt" 64)) ⇒ 
> ("woEB\351Qe\2626Hn\360\211\332g\336\331@\357\327\246n\326XL\344\334=\305\307\232\360\277\301\253\215\3108\202'\232\301\234\373\234\364\344\276ws\355YJQ"
>  "****************")
> 
> (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.

> So I would like to use this input, but I do not understand and
> cannot get example how to usei t, and I did review md5 and
> secure-hash functions and still... I need help.

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"?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]