• base26 Encoder/Decoder

    From Stefan Claas@21:1/5 to All on Fri Jan 19 21:05:20 2024
    Hi all,

    if you like the Diana Cryptosystem and want to
    use it with a foreign language, on an offline
    Computer, you may find my base26 Encoder/Decoder
    useful.

    https://github.com/stefanclaas/base26

    Regards
    Stefan
    --
    ----Ed25519 Signature---- 473619917a3d41e3151526e8cec73798239329fddcfb6c6c45298dde70497d1d d3a4ab324a690e10856c4d52024daa849e100f0a1604dbc8dd46f69f169db305

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Cri-Cri@21:1/5 to Stefan Claas on Fri Mar 15 22:40:12 2024
    On Fri, 19 Jan 2024 21:05:20 +0100, Stefan Claas wrote:

    if you like the Diana Cryptosystem and want to use it with a foreign language, on an offline Computer, you may find my base26 Encoder/Decoder useful.

    Found a Python version:
    https://pypi.org/project/base26/#files

    Example:

    import base26
    base26.encode(b'test')
    'EWJILIG'
    base26.decode('EWJILIG')
    b'test'

    --
    Cri-Cri

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Claas@21:1/5 to Cri-Cri on Sat Mar 16 14:30:45 2024
    Cri-Cri wrote:

    On Fri, 19 Jan 2024 21:05:20 +0100, Stefan Claas wrote:

    if you like the Diana Cryptosystem and want to use it with a foreign language, on an offline Computer, you may find my base26
    Encoder/Decoder useful.

    Found a Python version:
    https://pypi.org/project/base26/#files

    Example:

    import base26
    base26.encode(b'test')
    'EWJILIG'
    base26.decode('EWJILIG')
    b'test'


    Interesting, but the output differs from mine.

    $ echo -n 'test' | base26
    MEXDLEME

    I guess there is no defined standard (RFC) for
    base26, maybe I am wrong.

    Regards
    Stefan
    --
    ----Ed25519 Signature---- 6c34fa71ca251de62392a9753b6f7481817f7c89dcca433cd9f6e5a9211d233a 5a08cbd84d9a99b018f2705416ebac3dde33bf38bd35ca106c8a71cee9e45e0e

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Cri-Cri@21:1/5 to Stefan Claas on Sat Mar 16 19:48:00 2024
    On Sat, 16 Mar 2024 14:30:45 +0100, Stefan Claas wrote:

    $ echo -n 'test' | base26 MEXDLEME

    I guess there is no defined standard (RFC) for base26, maybe I am wrong.

    There ought to be. But, of course, maybe none of the math heads thinking
    these things through have returned with the verdict from their round table meeting yet? ;)

    Not sure what either of you guys used, but this page: https://www.dcode.fr/base-26-cipher
    ...claims there are two ways to start: A=0 or A=1

    Maybe that?

    He has a "machine" on his site you can compare things with. But it returns
    the result in numeric Base26, not as encoded letters:

    this here is a test
    338902 126182 226 0 337135

    Also, Python starts its arrays/lists with 0 for the first item where some
    other languages use 1. I have no idea what "Go" (was it?) uses.

    If I get a little free time I'll probably check the Python module against
    that page (linked above). It was fairly short.


    I've been fiddling with the HC-9 cipher that came out of that handy little machine the Swedish military used up until around 1995-ish. I've got some
    info about that coding from that site, it is very informative. So I'm
    currently all "ciphered out" and I want to spend some time with some other things for a while. :)

    --
    Cri-Cri

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Claas@21:1/5 to Cri-Cri on Sat Mar 16 21:13:03 2024
    Cri-Cri wrote:

    On Sat, 16 Mar 2024 14:30:45 +0100, Stefan Claas wrote:

    $ echo -n 'test' | base26 MEXDLEME

    I guess there is no defined standard (RFC) for base26, maybe I am
    wrong.

    There ought to be. But, of course, maybe none of the math heads
    thinking these things through have returned with the verdict from
    their round table meeting yet? ;)

    Not sure what either of you guys used, but this page: https://www.dcode.fr/base-26-cipher
    ...claims there are two ways to start: A=0 or A=1

    Maybe that?

    He has a "machine" on his site you can compare things with. But it
    returns the result in numeric Base26, not as encoded letters:

    this here is a test
    338902 126182 226 0 337135

    I saw that french page and ys it uses digits as output, which I don not
    want, because of using my output (from Unicode chars) for the Diana Cryptosystem.

    Also, Python starts its arrays/lists with 0 for the first item where
    some other languages use 1. I have no idea what "Go" (was it?) uses.

    Yes, it is Go Code and starts at 0.

    If I get a little free time I'll probably check the Python module
    against that page (linked above). It was fairly short.


    I've been fiddling with the HC-9 cipher that came out of that handy
    little machine the Swedish military used up until around 1995-ish.
    I've got some info about that coding from that site, it is very
    informative. So I'm currently all "ciphered out" and I want to spend
    some time with some other things for a while. :)

    HC-9, must admit, never heart of it but sounds interesting. I have to
    read about it.

    --
    Stefan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Claas@21:1/5 to Cri-Cri on Thu Apr 25 17:37:40 2024
    Cri-Cri wrote:

    On Fri, 19 Jan 2024 21:05:20 +0100, Stefan Claas wrote:

    if you like the Diana Cryptosystem and want to use it with a foreign language, on an offline Computer, you may find my base26 Encoder/Decoder useful.

    Found a Python version:
    https://pypi.org/project/base26/#files

    Example:

    import base26
    base26.encode(b'test')
    'EWJILIG'
    base26.decode('EWJILIG')
    b'test'


    I now have a Rust Version, derived from the Python library and
    it encodes 'test' with the same result, but when encoding with
    Rust, the Python code can not decode properly, while decoding
    from Python with Rust works. Oh, well ... :-(
    (Wish I was a Programmer!)

    --
    Regards
    Stefan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Claas@21:1/5 to Stefan Claas on Thu Apr 25 18:01:36 2024
    Stefan Claas wrote:

    Cri-Cri wrote:

    On Fri, 19 Jan 2024 21:05:20 +0100, Stefan Claas wrote:

    if you like the Diana Cryptosystem and want to use it with a foreign language, on an offline Computer, you may find my base26 Encoder/Decoder useful.

    Found a Python version:
    https://pypi.org/project/base26/#files

    Example:

    import base26
    base26.encode(b'test')
    'EWJILIG'
    base26.decode('EWJILIG')
    b'test'


    I now have a Rust Version, derived from the Python library and
    it encodes 'test' with the same result, but when encoding with
    Rust, the Python code can not decode properly, while decoding
    from Python with Rust works. Oh, well ... :-(
    (Wish I was a Programmer!)

    Ok, I figured out that my Python3 code example is bad. So the
    Rust Version works the same as the library. :-)

    $ python3
    Python 3.9.2 (default, Feb 28 2021, 17:03:44)
    [GCC 10.2.1 20210110] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    import base26
    base26.encode(b'The quick brown fox jumps over the lazy dog.') 'AAZCESYRPSBENRDWLUQLYETYZZJCPAHHAVEIPLIONRSBHYUEHANMAUZZQCSOGOXJEBILDQVWRGD' >>>
    $ echo -n 'AAZCESYRPSBENRDWLUQLYETYZZJCPAHHAVEIPLIONRSBHYUEHANMAUZZQCSOGOXJEBILDQVWRGD' | b26 -d
    The quick brown fox jumps over the lazy dog.
    $ echo -n 'Hello sci.crypt' | b26
    UQZGYLNMDHTUDTGJYKJRQGDKOC

    $ python3
    Python 3.9.2 (default, Feb 28 2021, 17:03:44)
    [GCC 10.2.1 20210110] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    import base26
    base26.decode('UQZGYLNMDHTUDTGJYKJRQGDKOC')
    b'Hello sci.crypt'


    Ok. everything is fine. :-)

    --
    Regards
    Stefan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Claas@21:1/5 to Stefan Claas on Fri Apr 26 18:26:57 2024
    Stefan Claas wrote:

    Stefan Claas wrote:

    [...]

    Ok. everything is fine. :-)

    Example Unicode text encoded, with -l Parameter for line-length:

    SASHXTRHYGJXHJBMKMWLUPZPTINOBPKNFSPZNFBWWXLWUNFRSGZHPACWHNFRFTGR

    Another example, an encrypted SMS message, done with Adiantum (FPE)
    and base26 encoded and grouped in five letter groups.

    JFMLM THPBQ RDZJD KTZEJ MOGKY BPCIY LTHNL FNSBA

    This allows one to create SMS messages on a little offline notebook
    and type it in an old mobile phone, or use, for example, Modem-Manager-GUI under Linux, to send encrypted SMS messages.

    P.S. Looks now like a Diana Cryptosystem message. ;-)

    --
    Regards
    Stefan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Claas@21:1/5 to Stefan Claas on Fri Apr 26 21:42:23 2024
    Stefan Claas wrote:

    Stefan Claas wrote:

    Stefan Claas wrote:

    [...]

    Ok. everything is fine. :-)

    Example Unicode text encoded, with -l Parameter for line-length:

    SASHXTRHYGJXHJBMKMWLUPZPTINOBPKNFSPZNFBWWXLWUNFRSGZHPACWHNFRFTGR

    Another example, an encrypted SMS message, done with Adiantum (FPE)
    and base26 encoded and grouped in five letter groups.

    JFMLM THPBQ RDZJD KTZEJ MOGKY BPCIY LTHNL FNSBA

    This allows one to create SMS messages on a little offline notebook
    and type it in an old mobile phone, or use, for example, Modem-Manager-GUI under Linux, to send encrypted SMS messages.

    P.S. Looks now like a Diana Cryptosystem message. ;-)


    Added Windows Release.

    https://github.com/stefanclaas/base26

    --
    Regards
    Stefan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Cri-Cri@21:1/5 to Stefan Claas on Sat Apr 27 13:10:27 2024
    On Thu, 25 Apr 2024 18:01:36 +0200, Stefan Claas wrote:

    Ok, I figured out that my Python3 code example is bad.

    I took the example that French site had and made this, a very naive
    approach to see what all the fuss is about. I used all strings and
    converted to an fro integer where needed:

    #---copy from here---------------------------
    """
    1. get input string
    2. convert this to base 10, where A=0
    3. length of input string, gives you the exponent to use for each step
    """

    # STEP #1
    s = input('text: ').upper()
    print(s)

    # STEP #2
    i = []
    for c in s:
    i.append(str(ord(c)-65).zfill(2))

    # STEP #3
    i.reverse()
    r = []
    for e in range(len(s)):
    r.append(str(int(i[e])*26**e).zfill(2))
    print(sum([int(t) for t in r]))
    #---copy to here---------------------------

    Example output:

    $ python test_b26.py
    text: dcode
    DCODE
    1415626 <<

    That number can then be encoded into text, simplest is using one digit for
    each letter:

    ''.join([chr(int(c)+65) for c in str(result)]) -> BEBFGCG

    Whether or not this is the "correct" way of doing it, well, ...

    """
    https://www.dcode.fr/base-26-cipher
    To code DCODE, written in base 26, convert it to base 10:
    D=3, C=2, O=14, D=3, E=4 which means that: 3×26⁴+2×26³+14×26²+3×26¹+4×26⁰=1415626 <<
    """

    What I fail to understand in the original Base26 Python module is, why the
    need for the things at the top:

    NOM = 851
    DENOM = 500

    Looks like magic numbers to me.

    The 'A' becoming zero problem my short example code handles such:

    $ python test_b26.py
    text: ape
    APE
    394
    DJE

    That French site said "0394". So, some corrections have to be added to my
    naive code, I suppose it should have been ADJE as output, but I'll leave
    that part as en exercise for my readers. ;)

    --
    Cri-Cri

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Claas@21:1/5 to Cri-Cri on Sat Apr 27 17:31:29 2024
    Cri-Cri wrote:

    What I fail to understand in the original Base26 Python module is, why the need for the things at the top:

    NOM = 851
    DENOM = 500

    Looks like magic numbers to me.

    I asked that myself and the answer, from AI, is:

    In this code, NOM and DENOM stand for “numerator” and “denominator”. They are used to calculate the length of the output when the input is being encoded or decoded.

    These calculations ensure that the length of the output is correctly rounded. The values of NOM and DENOM are chosen to reflect the ratio between the length of the input and the length of the output in the Base26 encoding.

    In this case, NOM = 851 and DENOM = 500, which means that the length of the output is about 85.1% of the length of the input when the input is being encoded, and about 58.8%
    of the length of the input when the input is being decoded.

    --
    Regards
    Stefan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Cri-Cri@21:1/5 to Stefan Claas on Sun Apr 28 07:58:12 2024
    On Sat, 27 Apr 2024 17:31:29 +0200, Stefan Claas wrote:

    In this case, NOM = 851 and DENOM = 500, which means that the length of
    the output is about 85.1% of the length of the input when the input is
    being encoded, and about 58.8%
    of the length of the input when the input is being decoded.

    Yeah, magic numbers. I don't like the concept of "about" here, since there
    is nothing "about" about it. ;)

    I suspect the concept of "about" is what is wrong with the implementation, since it isn't the same as what you got with your code. Or both are flawed
    and it should be something different altogether.

    Why didn't you ask your friend to write the encoder/decoder for you from scratch?

    If you used this approach with your Rust code, you should be able to use
    the same description to get it in whatever language you wanted.

    --
    Cri-Cri

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Claas@21:1/5 to Cri-Cri on Sun Apr 28 10:12:49 2024
    Cri-Cri wrote:

    On Sat, 27 Apr 2024 17:31:29 +0200, Stefan Claas wrote:

    In this case, NOM = 851 and DENOM = 500, which means that the length of
    the output is about 85.1% of the length of the input when the input is being encoded, and about 58.8%
    of the length of the input when the input is being decoded.

    Yeah, magic numbers. I don't like the concept of "about" here, since there
    is nothing "about" about it. ;)

    I suspect the concept of "about" is what is wrong with the implementation, since it isn't the same as what you got with your code. Or both are flawed and it should be something different altogether.

    Why didn't you ask your friend to write the encoder/decoder for you from scratch?

    If you used this approach with your Rust code, you should be able to use
    the same description to get it in whatever language you wanted.


    My Rust version works 100% the same as the Python3 implementation from the PyPI site and I needed an encoder/decoder that works with letters and not with digits,
    like the French site does.

    So, in the end people are free to choose which base26 approach they like to use,
    because there is no standard, like an RFC, available.

    If you use other base n encoders you will see, like in base64, base32, base58, base85, base91 etc. the base n system relies always on letters (and some digits and special characters).

    So I really see no problem here.

    --
    Regards
    Stefan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Claas@21:1/5 to Stefan Claas on Sun Apr 28 10:22:46 2024
    Stefan Claas wrote:

    If you use other base n encoders you will see, like in base64, base32, base58,
    base85, base91 etc. the base n system relies always on letters (and some digits and special characters).

    I mean base encoders/decoders and not the base n system.

    --
    Regards
    Stefan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Herbert Kleebauer@21:1/5 to Stefan Claas on Sun Apr 28 12:50:21 2024
    On 28.04.2024 10:12, Stefan Claas wrote:

    So, in the end people are free to choose which base26 approach they like to use,
    because there is no standard, like an RFC, available.

    But base26 doesn't make much sense. How big are the chunks of the
    data input stream you encode in base26? If you encode each byte,
    you need 2 digits for the byte, which is the same as base16 (hex format).
    The same is true for 2 and 3 byte chunks (4 and 6 digits). Starting
    with 4 byte chunks you can save one digit (7 instead of 8 for hex).
    The next step is at 7 byte chunks (12 instead of 14 digits for hex).
    But this is also the biggest size which you can handle with 64 bit
    arithmetic. Starting with 11 byte chunks you can save 3 digits (19
    instead of 22 for hex), but this already requires long number
    arithmetic.

    So, if you can't use base32 at least, better stay at base16 (hex format) instead of base26. There is only a small advantage in size, but a big disadvantage in computing time and you have to cope with padding if the
    message length is not a multiple of the chunk length.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Claas@21:1/5 to Stefan Claas on Sun Apr 28 13:44:17 2024
    Stefan Claas wrote:

    Example:

    $ echo -n 'Hello sci.crypt! :-)' | base16 48656c6c6f207363692e637279707421203a2d29

    $ echo -n 'Hello sci.crypt! :-)' | base32
    JBSWY3DPEBZWG2JOMNZHS4DUEEQDULJJ

    $ echo -n 'Hello sci.crypt! :-)' | cbase32
    91JPRV3F41SP6T9ECDS7JW3M44G3MB99

    $ echo -n 'Hello sci.crypt! :-)' | base26 | ug -g
    GNUKB WRRLQ QCISN UJYEH SKYLR PJHKG YPTEA

    Hope this makes sense!


    P.S I tested this yesterday also with my Telefax machine and
    freely available OCR software and had no errors, with base26.

    --
    Regards
    Stefan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Claas@21:1/5 to Herbert Kleebauer on Sun Apr 28 13:32:20 2024
    Herbert Kleebauer wrote:

    On 28.04.2024 10:12, Stefan Claas wrote:

    So, in the end people are free to choose which base26 approach they like to use,
    because there is no standard, like an RFC, available.

    But base26 doesn't make much sense. How big are the chunks of the
    data input stream you encode in base26? If you encode each byte,
    you need 2 digits for the byte, which is the same as base16 (hex format).
    The same is true for 2 and 3 byte chunks (4 and 6 digits). Starting
    with 4 byte chunks you can save one digit (7 instead of 8 for hex).
    The next step is at 7 byte chunks (12 instead of 14 digits for hex).
    But this is also the biggest size which you can handle with 64 bit arithmetic. Starting with 11 byte chunks you can save 3 digits (19
    instead of 22 for hex), but this already requires long number
    arithmetic.

    So, if you can't use base32 at least, better stay at base16 (hex format) instead of base26. There is only a small advantage in size, but a big disadvantage in computing time and you have to cope with padding if the message length is not a multiple of the chunk length.


    Thanks for your reply, much appreciated!

    Well, the reason why I like this base26 implementation is I can use it
    for the Diana Cryptosystem or the Dein Star straddling checkerboard,
    when using foreign languages or transmitting small binary blobs.

    The second reason, I can use this also for typing in small encrypted messages more easily, when using Format Preserving Encryption (FPE), in an old feature phone, for sending text messages (SMS), when grouping the string as five letter groups, to avoid typos.

    Example:

    $ echo -n 'Hello sci.crypt! :-)' | base16 48656c6c6f207363692e637279707421203a2d29

    $ echo -n 'Hello sci.crypt! :-)' | base32
    JBSWY3DPEBZWG2JOMNZHS4DUEEQDULJJ

    $ echo -n 'Hello sci.crypt! :-)' | cbase32
    91JPRV3F41SP6T9ECDS7JW3M44G3MB99

    $ echo -n 'Hello sci.crypt! :-)' | base26 | ug -g
    GNUKB WRRLQ QCISN UJYEH SKYLR PJHKG YPTEA

    Hope this makes sense!

    --
    Regards
    Stefan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Herbert Kleebauer@21:1/5 to Stefan Claas on Sun Apr 28 14:53:19 2024
    On 28.04.2024 13:32, Stefan Claas wrote:

    $ echo -n 'Hello sci.crypt! :-)' | base16 48656c6c6f207363692e637279707421203a2d29

    $ echo -n 'Hello sci.crypt! :-)' | base26 | ug -g
    GNUKB WRRLQ QCISN UJYEH SKYLR PJHKG YPTEA


    I still don't understand it. In this example you have
    a 20 byte String: Hello sci.crypt! :-)

    The base16 (hex) conversion is trivial: you take a
    single byte of the input string and replace it by
    2 hex characters. No padding necessary, because the
    chunk length is 1 byte and so the string length is
    always a multiple of the chunk length.

    But how does your base26 coding work. Take you four bytes
    of the input string and then convert this 32 bit number
    to base26 resulting in a 7 digit base26 number? There
    are 5 of this 4 byte chunks which gives a total of 35
    base26 digits. But how do you handle padding if the
    input string length is not a multiple of 4?

    Or do you treat the complete string as a single number 0x48656c6c6f207363692e637279707421203a2d29 and convert
    this 160 bit number to a single base26 number? This would
    also result in a 35 digit base26 number, but would
    require long number arithmetic and consume a lot of
    computing power (suppose the input string is 1 MByte or
    even 1 GByte). In this case you don't have a problem
    with padding but with leading zeroes.

    But I still don't understand the advantage over base16.
    If you only can use A-Z as transferable digits, you can
    use an alternative to the standard hex encoding:

    0 A or Q
    1 B or R
    2 C or S
    3 D or T
    4 E or U
    5 F or V
    6 G or W
    7 H or X
    8 I or Y
    9 J or Z
    10 K
    11 L
    12 M
    13 N
    14 O
    15 P

    Because there are two ways to encode 0-9, you
    can use this to send a second data stream. If
    A-J is used a 0 bit transferred and if Q-Z is used
    a 1 bit is transferred on this second channel. You
    can use this for example for a check sum or an
    error correcting code.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Claas@21:1/5 to Herbert Kleebauer on Sun Apr 28 15:45:19 2024
    Herbert Kleebauer wrote:

    But how does your base26 coding work. Take you four bytes
    of the input string and then convert this 32 bit number
    to base26 resulting in a 7 digit base26 number? There
    are 5 of this 4 byte chunks which gives a total of 35
    base26 digits. But how do you handle padding if the
    input string length is not a multiple of 4?

    Or do you treat the complete string as a single number 0x48656c6c6f207363692e637279707421203a2d29 and convert
    this 160 bit number to a single base26 number? This would
    also result in a 35 digit base26 number, but would
    require long number arithmetic and consume a lot of
    computing power (suppose the input string is 1 MByte or
    even 1 GByte). In this case you don't have a problem
    with padding but with leading zeroes.

    Sorry (I get a red face ...) The Rust code is derived
    from the Python3 library without thinking to much about
    the logic behind it, so I can't answer your questions
    correctly!

    For me it was sufficient that the code works, as expected
    for small payloads, when comparing the output with the
    Python3 library. The program is not intended for encoding
    large (binary) payloads and only meant as a helper program
    for the Diana Cryptosystem or Dein Star etc.

    I am no programmer like you guys are but always appreciate
    the comments! And I was in need for a binary program solution,
    instead of using Python scripts, which I do not like.

    But I still don't understand the advantage over base16.
    If you only can use A-Z as transferable digits, you can
    use an alternative to the standard hex encoding:

    0 A or Q
    1 B or R
    2 C or S
    3 D or T
    4 E or U
    5 F or V
    6 G or W
    7 H or X
    8 I or Y
    9 J or Z
    10 K
    11 L
    12 M
    13 N
    14 O
    15 P

    Because there are two ways to encode 0-9, you
    can use this to send a second data stream. If
    A-J is used a 0 bit transferred and if Q-Z is used
    a 1 bit is transferred on this second channel. You
    can use this for example for a check sum or an
    error correcting code.

    Thank you for explaining!

    --
    Regards
    Stefan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Claas@21:1/5 to Herbert Kleebauer on Sun Apr 28 16:56:08 2024
    Herbert Kleebauer wrote:

    If you only can use A-Z as transferable digits, you can
    use an alternative to the standard hex encoding:

    0 A or Q
    1 B or R
    2 C or S
    3 D or T
    4 E or U
    5 F or V
    6 G or W
    7 H or X
    8 I or Y
    9 J or Z
    10 K
    11 L
    12 M
    13 N
    14 O
    15 P

    Because there are two ways to encode 0-9, you
    can use this to send a second data stream. If
    A-J is used a 0 bit transferred and if Q-Z is used
    a 1 bit is transferred on this second channel. You
    can use this for example for a check sum or an
    error correcting code.

    Would this be the correct output for A-Z encoding?

    $ echo -n 'sci.crypt is cool! :-)' | ./az XDGTWJCOWDHSXJHQXECQWJHTSAGTWPGPWMCRSADKSNCZ

    $ echo -n 'sci.crypt is cool! :-)' | base16 7363692e637279707420697320636f6f6c21203a2d29

    --
    Regards
    Stefan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Claas@21:1/5 to Stefan Claas on Mon Apr 29 19:42:50 2024
    Stefan Claas wrote:

    Herbert Kleebauer wrote:

    If you only can use A-Z as transferable digits, you can
    use an alternative to the standard hex encoding:

    0 A or Q
    1 B or R
    2 C or S
    3 D or T
    4 E or U
    5 F or V
    6 G or W
    7 H or X
    8 I or Y
    9 J or Z
    10 K
    11 L
    12 M
    13 N
    14 O
    15 P

    Because there are two ways to encode 0-9, you
    can use this to send a second data stream. If
    A-J is used a 0 bit transferred and if Q-Z is used
    a 1 bit is transferred on this second channel. You
    can use this for example for a check sum or an
    error correcting code.

    Would this be the correct output for A-Z encoding?

    $ echo -n 'sci.crypt is cool! :-)' | ./az XDGTWJCOWDHSXJHQXECQWJHTSAGTWPGPWMCRSADKSNCZ

    $ echo -n 'sci.crypt is cool! :-)' | base16 7363692e637279707420697320636f6f6c21203a2d29

    I would say yes, because the table matches the hex
    values and the encoder/decoder is also fast enough
    to handle 1 GB of data, for example.

    Well, a new tool to play with, thanks to Herbert's
    suggestion. :-)

    --
    Regards
    Stefan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Claas@21:1/5 to Stefan Claas on Tue Apr 30 16:43:42 2024
    Stefan Claas wrote:

    Well, a new tool to play with, thanks to Herbert's
    suggestion. :-)

    Ok. I created 1000 random bytes with OpenSSL, converted
    them with az, with a line length of 50 characters set.

    Then the file was opened in LibreOffice, with the settings
    of 16 pt, Liberation Mono font and saved as .pdf. With
    these settings, 2000 characters fit exactly in an A4 page.

    To send a Telefax to my Fax machine I used an online
    service, where I have a paid account.

    Once the Fax was received I scanned it with 200 dpi and
    saved it as .png. For OCR translation I used Boxsoft Free
    OCR, for Windows, because Tesseract gave me more errors
    in the past. I only had one error in one line, which showed
    at the beginning a dot and space, which I removed manually.

    Again I used az to decode the file and a diff showed no
    differences in the binaries.

    Here is a URL with the files, in case someone likes to look
    at them:

    <https://1drv.ms/f/s!Agn0bI_1Rm5ehnT1oJLYw5HafvGB?e=R6i09c>

    --
    Regards
    Stefan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Herbert Kleebauer@21:1/5 to Stefan Claas on Tue Apr 30 21:24:54 2024
    On 30.04.2024 16:43, Stefan Claas wrote:

    Ok. I created 1000 random bytes with OpenSSL, converted
    them with az, with a line length of 50 characters set.

    Then the file was opened in LibreOffice, with the settings
    of 16 pt, Liberation Mono font and saved as .pdf. With
    these settings, 2000 characters fit exactly in an A4 page.

    But QR code exists since a long time. This is also
    a pdf with one A4 page, but if you decode it, you get
    a 10 kByte jpg, which is 10x the amount of data of your
    text page.

    http://onlib.de/temp/demo.pdf

    And if you have more data to transfer, use a QR code
    video, for example:

    http://onlib.de/temp/qr.mp4

    You can upload your video to youtube, so anybody can
    download and decode it.

    If you decode the QR code video, you will get a zip file
    with some pictures. The password for the pictures is:
    "The quick brown fox jump"

    And if you want to encrypt or hide the video, take a
    look at:

    http://onlib.de/pub/pfv/

    For example, the video:

    http://onlib.de/pub/pfv/demo.mp4

    has one unencrypted video (so you can just click the
    above link and watch the unencrypted video) and two
    encrypted videos and one zip file which you can only
    access if you download the file and enter the correct
    password.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Claas@21:1/5 to Herbert Kleebauer on Wed May 1 10:29:26 2024
    Herbert Kleebauer wrote:

    On 30.04.2024 16:43, Stefan Claas wrote:

    Ok. I created 1000 random bytes with OpenSSL, converted
    them with az, with a line length of 50 characters set.

    Then the file was opened in LibreOffice, with the settings
    of 16 pt, Liberation Mono font and saved as .pdf. With
    these settings, 2000 characters fit exactly in an A4 page.

    But QR code exists since a long time. This is also
    a pdf with one A4 page, but if you decode it, you get
    a 10 kByte jpg, which is 10x the amount of data of your
    text page.

    http://onlib.de/temp/demo.pdf

    And if you have more data to transfer, use a QR code
    video, for example:

    http://onlib.de/temp/qr.mp4

    You can upload your video to youtube, so anybody can
    download and decode it.

    If you decode the QR code video, you will get a zip file
    with some pictures. The password for the pictures is:
    "The quick brown fox jump"


    I decoded the image and had one error in the certutil file
    (one byte missing in one line at the end). The video was
    also a certutil file, but with to many errors, so it wrote
    a bad .mp4, which I could not decode.

    How did you manage to precisely insert 12 QR-Codes nicely on
    an A4 page?

    --
    Regards
    Stefan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Claas@21:1/5 to Herbert Kleebauer on Wed May 1 11:51:00 2024
    Herbert Kleebauer wrote:

    On 01.05.2024 10:29, Stefan Claas wrote:

    I decoded the image and had one error in the certutil file
    (one byte missing in one line at the end). The video was
    also a certutil file, but with to many errors, so it wrote
    a bad .mp4, which I could not decode.

    How did you manage to precisely insert 12 QR-Codes nicely on
    an A4 page?

    Some time ago I wrote a batch to make a paper backup
    from a 13 kByte binary file (so it will make only two
    pages with 12 QR codes each). The input file is hard
    coded (t.jpg in this case). qrencode.exe I downloaded
    somewhere from the internet and convert.exe is the
    universal picture tool from https://imagemagick.org .
    split.exe just splits the input file in small chunks
    to be encoded in single QR code (source at the end of
    this post). To get the binary back from the paper print,
    you have just to start a text editor and scan all the
    QR codes with a Bluetooth QR code scanner (which works
    like an external Bluetooth keyboard). Then execute the
    generated batch file to generate the binary.

    [...]

    Thanks a lot or your help, much appreciated!

    Und einen schönen 1. Mai! :-)

    --
    Grüße
    Regards
    Stefan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Herbert Kleebauer@21:1/5 to Stefan Claas on Wed May 1 11:40:17 2024
    On 01.05.2024 10:29, Stefan Claas wrote:

    I decoded the image and had one error in the certutil file
    (one byte missing in one line at the end). The video was
    also a certutil file, but with to many errors, so it wrote
    a bad .mp4, which I could not decode.

    How did you manage to precisely insert 12 QR-Codes nicely on
    an A4 page?

    Some time ago I wrote a batch to make a paper backup
    from a 13 kByte binary file (so it will make only two
    pages with 12 QR codes each). The input file is hard
    coded (t.jpg in this case). qrencode.exe I downloaded
    somewhere from the internet and convert.exe is the
    universal picture tool from https://imagemagick.org .
    split.exe just splits the input file in small chunks
    to be encoded in single QR code (source at the end of
    this post). To get the binary back from the paper print,
    you have just to start a text editor and scan all the
    QR codes with a Bluetooth QR code scanner (which works
    like an external Bluetooth keyboard). Then execute the
    generated batch file to generate the binary.


    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :::::::::::::::: start batch ::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

    ::@echo off

    certutil -f -decode %~f0 blank.png>nul
    tmp.txt echo @echo off
    tmp.txt echo certutil -f -decode %%~f0 dmeo.jpg^>nul
    tmp.txt echo goto :eof

    certutil -f -encode t.jpg input.txt
    copy /b tmp.txt + input.txt input.b64
    del tmp.txt
    del input.txt

    split input.b64
    del input.b64


    for %%i in (*.spt) do (
    d:\dos622\qrencode\qrencode.exe -o %%i.png -m 8 -s 4 --strict-version -v 20 -8 -r %%i
    del %%i)

    for /l %%i in (101,1,124) do if not exist %%i.spt.png copy blank.png %%i.spt.png
    del blank.png

    d:\dos622\befehle\convert.exe 101.spt.png 102.spt.png 103.spt.png +append 1.png
    d:\dos622\befehle\convert.exe 104.spt.png 105.spt.png 106.spt.png +append 2.png
    d:\dos622\befehle\convert.exe 107.spt.png 108.spt.png 109.spt.png +append 3.png
    d:\dos622\befehle\convert.exe 110.spt.png 111.spt.png 112.spt.png +append 4.png

    d:\dos622\befehle\convert.exe 1.png 2.png 3.png 4.png -append seite1.png


    d:\dos622\befehle\convert.exe 113.spt.png 114.spt.png 115.spt.png +append 1.png
    d:\dos622\befehle\convert.exe 116.spt.png 117.spt.png 118.spt.png +append 2.png
    d:\dos622\befehle\convert.exe 119.spt.png 120.spt.png 121.spt.png +append 3.png
    d:\dos622\befehle\convert.exe 122.spt.png 123.spt.png 124.spt.png +append 4.png

    d:\dos622\befehle\convert.exe 1.png 2.png 3.png 4.png -append seite2.png

    for /l %%i in (100,1,124) do del %%i.spt.png
    for /l %%i in (1,1,4) do del %%i.png

    pause
    goto :eof


    -----BEGIN CERTIFICATE----- iVBORw0KGgoAAAANSUhEUgAAAcQAAAHEAQMAAACdkchcAAAABlBMVEUAAAD///+l 2Z/dAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAaUlEQVR42u3LIQEAAAgDsPdPSwPe AYHa/LJHE9M0TdM0TdM0TdM0TdM0TdM0TdM0TdM0TdM0TdM0TdM0TdM0TdM0TdM0 TdM0TdM0TdM0TdM0TdM0TdM0TdM0TdM0TdM0TdM0TdM0TfNhFu6JKr3/W3VpAAAA
    AElFTkSuQmCC
    -----END CERTIFICATE-----

    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :::::::::::::::: end batch ::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::



    Here the batch to decode the QR code video qr.mp4 .
    ffmpeg.exe is the universal video tool from https://ffmpeg.org/
    and qrtool.exe I downloaded somewhere from the Internet.


    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :::::::::::::::: end batch ::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

    ::@echo off
    d:\dos622\ffmpeg\bin\ffmpeg.exe -i qr.mp4 0%%07d.frame.png

    for %%i in (*.frame.png) do (
    D:\dos622\qrtool\qrtool.exe decode %%i>>output.b64
    del %%i)


    certutil -f -decode output.b64 output.zip
    del output.b64

    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    x:::::::::::::::: end batch ::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::



    And here the source of split.exe:

    #define size1 674
    #include <stdio.h>
    FILE *in, *out, *fopen();
    char buf[size1+5];
    char name[16]={'0','0','0','0','0','0','0','1','.','s','p','t',0};


    void print_string();
    void ende();
    void exit();

    main(nargs,args) int nargs; char *args[];
    {if (nargs!=2) ende(1);
    int i,n,m;
    in = fopen(args[1],"rb"); if (in==NULL) ende(2);

    do {n=fread(buf,1,size1,in);
    if (n == 0) break;
    out = fopen(name,"wb"); if (out==NULL) ende(3);
    m=fwrite(buf,1,n,out);
    fclose(out);
    i=7; name[i]++;
    while (i) {if (name[i] == '9'+1) {name[i]='0'; name[--i]++;} else break;}
    } while (n == size1);

    ende(0);
    }


    void print_string(p) char *p; {while (*p) putc(*p++,stdout);}

    void ende(i) int i;
    {static char *(meld[]) = {
    /* 0 */ "no errors" ,
    /* 1 */ "usage: ins infile outfile" ,
    /* 2 */ "can't open input file" ,
    /* 3 */ "can't open output file" ,
    /* 4 */ "you never should read this" ,
    /* 5 */ "you never should read this" ,
    /* 6 */ "you never should read this" ,
    };

    print_string("\n"); print_string(meld[i]); print_string("\n");
    if (in!=NULL) fclose(in);
    if (out!=NULL) fclose(out);
    exit(0);
    }

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Claas@21:1/5 to Stefan Claas on Thu May 2 16:10:49 2024
    Stefan Claas wrote:

    Herbert Kleebauer wrote:

    On 01.05.2024 10:29, Stefan Claas wrote:

    I decoded the image and had one error in the certutil file
    (one byte missing in one line at the end). The video was
    also a certutil file, but with to many errors, so it wrote
    a bad .mp4, which I could not decode.

    How did you manage to precisely insert 12 QR-Codes nicely on
    an A4 page?

    Some time ago I wrote a batch to make a paper backup
    from a 13 kByte binary file (so it will make only two
    pages with 12 QR codes each). The input file is hard
    coded (t.jpg in this case). qrencode.exe I downloaded
    somewhere from the internet and convert.exe is the
    universal picture tool from https://imagemagick.org .
    split.exe just splits the input file in small chunks
    to be encoded in single QR code (source at the end of
    this post). To get the binary back from the paper print,
    you have just to start a text editor and scan all the
    QR codes with a Bluetooth QR code scanner (which works
    like an external Bluetooth keyboard). Then execute the
    generated batch file to generate the binary.

    [...]

    Thanks a lot or your help, much appreciated!

    While I still cannot decode the video, I have now my own
    solution.

    Here is the Python3 code:

    import qrcode
    import os
    import argparse
    import shutil
    from pyzbar.pyzbar import decode
    from PIL import Image
    import base64

    parser = argparse.ArgumentParser()
    parser.add_argument('-f', '--file', help='File to convert to/from QR codes') parser.add_argument('-e', '--encode', help='Directory to save QR codes', default=None)
    parser.add_argument('-d', '--decode', help='Directory to load QR codes from', default=None)
    args = parser.parse_args()

    def file_to_qrcodes(file_path, directory):
    with open(file_path, 'rb') as f:
    counter = 0
    while True:
    data = f.read(1024) # Read in chunks of 1024 bytes
    if not data:
    break
    encoded_data = base64.b64encode(data)
    qr = qrcode.QRCode(
    version=1,
    error_correction=qrcode.constants.ERROR_CORRECT_L,
    box_size=10,
    border=4,
    )
    qr.add_data(encoded_data)
    qr.make(fit=True)
    img = qr.make_image(fill_color="black", back_color="white")
    img.save(os.path.join(directory, f'qr{counter}.png'))
    counter += 1

    def qrcodes_to_file(directory, output_file):
    files = sorted([f for f in os.listdir(directory) if f.startswith('qr') and f.endswith('.png')],
    key=lambda x: int(x[2:-4]))
    with open(output_file, 'wb') as f:
    for file in files:
    decoded_objects = decode(Image.open(os.path.join(directory, file)))
    if decoded_objects:
    encoded_data = decoded_objects[0].data
    data = base64.b64decode(encoded_data)
    f.write(data)

    if args.file and (args.encode or args.decode):
    if args.encode:
    if not os.path.exists(args.encode):
    os.makedirs(args.encode)
    file_to_qrcodes(args.file, args.encode)
    if args.decode:
    if os.path.exists(args.decode):
    qrcodes_to_file(args.decode, args.file)

    and two bash scripts, for making a movie and for extracing the frames.

    #!/bin/bash
    #mm - make move from .png files
    FOLDERNAME="$1"

    cat $(find $FOLDERNAME -maxdepth 1 -name "*.png" | sort -V) | ffmpeg -framerate 25 -i - output.mp4

    #!/bin/bash
    #ef - extracts QR-Codes from an .mp4 file in a folder

    FOLDERFILENAME="$1"
    DIRNAME=$(dirname "$FOLDERFILENAME")
    BASENAME=$(basename "$FOLDERFILENAME" .mp4)

    ffmpeg -i "$FOLDERFILENAME" -start_number 0 "$DIRNAME/qr%d.png"

    --
    Regards
    Stefan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Claas@21:1/5 to Stefan Claas on Sat May 4 15:09:12 2024
    Stefan Claas wrote:

    While I still cannot decode the video, I have now my own
    solution.

    Here is the Python3 code:

    import qrcode
    import os
    import argparse
    import shutil
    from pyzbar.pyzbar import decode
    from PIL import Image
    import base64

    parser = argparse.ArgumentParser()
    parser.add_argument('-f', '--file', help='File to convert to/from QR codes') parser.add_argument('-e', '--encode', help='Directory to save QR codes', default=None)
    parser.add_argument('-d', '--decode', help='Directory to load QR codes from', default=None)
    args = parser.parse_args()

    def file_to_qrcodes(file_path, directory):
    with open(file_path, 'rb') as f:
    counter = 0

    Set counter to 1 for my following bash script[1].

    ffmpeg -i "$FOLDERFILENAME" -start_number 0 "$DIRNAME/qr%d.png"

    and remove -start_number 0

    [1] <https://github.com/stefanclaas/QR-Code-Helpers/blob/main/qr2page.sh>

    which allows you to print QR-Codes, nicely formatted, on paper, like
    Herbert has shown in his example.

    --
    Regards
    Stefan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Claas@21:1/5 to Stefan Claas on Sat May 4 19:39:49 2024
    Stefan Claas wrote:

    Stefan Claas wrote:

    While I still cannot decode the video, I have now my own
    solution.

    Here is the Python3 code:

    import qrcode
    import os
    import argparse
    import shutil
    from pyzbar.pyzbar import decode
    from PIL import Image
    import base64

    parser = argparse.ArgumentParser()
    parser.add_argument('-f', '--file', help='File to convert to/from QR codes')
    parser.add_argument('-e', '--encode', help='Directory to save QR codes', default=None)
    parser.add_argument('-d', '--decode', help='Directory to load QR codes from', default=None)
    args = parser.parse_args()

    def file_to_qrcodes(file_path, directory):
    with open(file_path, 'rb') as f:
    counter = 0

    Set counter to 1 for my following bash script[1].

    ffmpeg -i "$FOLDERFILENAME" -start_number 0 "$DIRNAME/qr%d.png"

    and remove -start_number 0

    [1] <https://github.com/stefanclaas/QR-Code-Helpers/blob/main/qr2page.sh>

    which allows you to print QR-Codes, nicely formatted, on paper, like
    Herbert has shown in his example.

    I have updated my pad program with an additional bash script so that
    users can pad there files, prior converting. That way the last frame
    or QR-Code in a document has the same size as the others. Padding can
    later been removed, with my pad program, from the file.

    https://github.com/stefanclaas/pad

    --
    Regards
    Stefan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)