[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/base32 49cb6d5468 078/103: Implement the base32hex encodin
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/base32 49cb6d5468 078/103: Implement the base32hex encoding from RFC4648 |
Date: |
Sat, 10 Feb 2024 13:00:10 -0500 (EST) |
branch: elpa/base32
commit 49cb6d5468d0e06badaa9ab2458c636110f13081
Author: Vivek Das Mohapatra <vivek@collabora.com>
Commit: Vivek Das Mohapatra <vivek@collabora.com>
Implement the base32hex encoding from RFC4648
Mechanically this is a base32 encoding witha slightly different
dictionary but RFC4648 indicates it should _not_ be considered a
base32 encoding, nor should it be called base32.
It should be called base32hex.
---
base32.el | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/base32.el b/base32.el
index 5ef61d9c11..1e4304b214 100644
--- a/base32.el
+++ b/base32.el
@@ -20,6 +20,12 @@
possible 5bit value (0-31) at that index, plus a padding character
at index 32.")
+(defconst base32-hex-dictionary
+ [?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9 ?A ?B ?C ?D ?E ?F
+ ?G ?H ?I ?J ?K ?L ?M ?N ?O ?P ?Q ?R ?S ?T ?U ?V ?=]
+ "The default base32hex dictionary.
+\nLike ‘base32-dictionary’ but for the base32hex encoding.")
+
(defun base32-lsh (v c)
"Shift integer V by C bits to the left.
Shift rightwards if C is negative.
@@ -162,5 +168,13 @@ DICTIONARY defaults to ‘base32-dictionary’."
(base32--nth-5bit-set output i chunk))
(if (< output-shorten 0) (substring output 0 output-shorten) output)))
+(defun base32-hex-encode (input)
+ "Encode INPUT bytes as base32hex."
+ (base32-encode input base32-hex-dictionary))
+
+(defun base32-hex-decode (input)
+ "Decode INPUT bytes as base32hex."
+ (base32-decode input base32-hex-dictionary))
+
(provide 'base32)
;;; base32.el ends here
- [nongnu] elpa/base32 4492236c1f 055/103: Squash some warnings when byte-compiling the tests, (continued)
- [nongnu] elpa/base32 4492236c1f 055/103: Squash some warnings when byte-compiling the tests, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 a15c27157a 050/103: Checkdoc incorrectly detects .\n as "not a complete sentence", ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 bd7959a5ef 058/103: Add a LICENSE (sic) to match the SPDX entries, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 d435f806a0 059/103: Documentation changes related to the Great Renaming, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 7f0fe12bce 063/103: Fix tests after the Great Renaming, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 4708406887 067/103: Add comm to package's keywords, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 6843417e38 068/103: Rename interactive entry point from totp to totp-auth, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 c31034feef 069/103: Fix the totp-auth-hmac.el footer comment, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 5e5f311775 077/103: Fix a checkdoc warning in base32-lsh, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 60dbfaf621 079/103: Use the warning-suppressing lsh wrapper from base32.el, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 49cb6d5468 078/103: Implement the base32hex encoding from RFC4648,
ELPA Syncer <=
- [nongnu] elpa/base32 a41fe7d0f7 072/103: Trivia: fix markup in test file docstring, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 ed4feed432 080/103: Fix a checkdoc warning., ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 c04d223e11 074/103: Fix a docstring xref, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 269044a4a2 082/103: Replace a single use of cl-case with cond, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 95af9632f3 070/103: Wrap lsh in base32.el to suppress misleading lsh vs ash warning, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 11199b1d22 085/103: Our default base32 dictionary is uppercase only, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 49f2e5e7ad 093/103: Add an autoload for the OTP export function, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 5fa6529ace 103/103: Fix another stray docstring reference, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 b048113b66 100/103: Allow user to create secrets interactively, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 19b6939cca 098/103: Prefer the "TOTP" secrets collection over "login" (if it exists), ELPA Syncer, 2024/02/10