• Bcrypt for DOS

    From Kerr-Mudd, John@admin@127.0.0.1 to alt.lang.asm on Tue Feb 11 10:42:45 2025
    From Newsgroup: alt.lang.asm

    swaps adjacent pairs of letters (but not if either are <'A') in text from stdin

    Now in 42 bytes

    B4 3F B5 FE BA 41 01 CD 21 91 E3 1D 51 89 D6 AC
    38 D0 72 0D 38 14 72 09 86 04 88 44 FF 46 49 74
    02 E2 EC 59 43 B4 40 CD 21 C3


    e.g.

    type kk.txt
    Oh my God, they killed Kenny!

    bcrypt1g<kk.txt
    hO ym oGd, htye ikllde eKnny!





    (Yes I know, it's not a kenny code converter but I've used the same test
    file)
    --
    Bah, and indeed Humbug.
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From jayjwa@jayjwa@atr2.ath.cx.invalid to alt.lang.asm on Mon Sep 7 20:44:19 2026
    From Newsgroup: alt.lang.asm

    "Kerr-Mudd, John" <admin@127.0.0.1> writes:

    type kk.txt
    Oh my God, they killed Kenny!

    bcrypt1g<kk.txt
    hO ym oGd, htye ikllde eKnny!



    @exec budcry
    LINK: Loading
    [LNKXCT BUDCRY execution]
    Enter the BuddCrypt code text, or encoded text to decode.
    * Oh my God, they killed Kenny!
    hO ym oGd, htye ikllde eKnny!
    @cont
    Enter the BuddCrypt code text, or encoded text to decode.
    * hO ym oGd, htye ikllde eKnny!
    Oh my God, they killed Kenny!
    @cont
    Enter the BuddCrypt code text, or encoded text to decode.
    * Oh my dog. :-))) They gilled Kenwick.
    hO ym odg. :-))) hTye igllde eKwncik.
    @cont
    Enter the BuddCrypt code text, or encoded text to decode.
    * hO ym odg. :-))) hTye igllde eKwncik.
    Oh my dog. :-))) They gilled Kenwick.


    (Yes I know, it's not a kenny code converter but I've used the same test file)

    Kenny Code is a different algorith, yes? This looks like BuddCrypt.

    It could be much smaller, doesn't really need a stack, has some error
    checking and user prompts but does the job. TOPS-20 can take text off
    the command line but requires more code. I don't think it can do
    stdin/stdout redirection so I used RDTTY%. Originally I was just
    checking that characters where in range but I see your solution looks at
    words so I had to modify the code for that with another ~6 lines or so.

    It's about so big:
    @vdir budcry.*

    DSK1:<PROGRAMMING>
    BUDCRY.EXE.3;P775252 2 1024(36) 7-Sep-2026 20:37:16 JAYJWA
    .MAC.3;P775252 2 4799(7) 7-Sep-2026 20:35:39 JAYJWA
    .REL.3;P775252 1 210(36) 7-Sep-2026 20:37:13 JAYJWA

    Total of 5 pages in 3 files

    PDP-10 comparisons are botally tackware; there has to be a better way to
    check ranges. Maybe a macro setting flags?


    comment $
    BuddCrypt (https://github.com/vallor/BuddCrypt/blob/main/BuddCrypt.pl)
    in MACRO-20 for the DECSYSTEM-20.

    Receive a line of text from the user and swap the character and its
    following adjacent character as long as they both are in the range
    [A..Z], [a..z] (0o101..0o132, 0o141..0o172). Skip spaces (0o40).

    Run the program again on the outputted text to get the original
    back since the encoder is the same as the decoder routine.
    $
    title budcry
    search monsym, macsym ; Pull in symbols
    STDAC. ; Label accums for us

    ssize==2 ; Stack size
    strsize==170 ; Max string size in octal

    buffer: block strsize / 5 ; Input buff, 5 chars a word ptrbuf: point 7, buffer ; 7bit pointer into buffer stack: block ssize ; Place for stack

    ; Define an error macro that gives the general error type and
    ; exits to the monitor, non-restartable. Call with error text param.
    define ERROUT (errtxt) <
    hrroi t1, [asciz /Error on errtxt . Exiting./]
    psout% ;; Print error message to TTY
    haltf% ;; Exit to monitor
    jrst .-1 ;; Rich says do this


    subttl Main
    start: move p, [iowd ssize, stack] ; Setup stack w/guard
    TMSG <Enter the BuddCrypt code text, or encoded text to decode.
    * >
    move t1, ptrbuf ; Set up RDTTY% buffer
    movei t2, strsize ; Max num of chars to read
    hrroi t3, [asciz /Input string? /] ; Reprompter prompt
    rdtty% ; Get user's string, minus \r\n
    erjmp [ERROUT (RDTTY%)] ; Macro handles error

    pushj p, encode ; Call en/decoder routine

    subttl Output
    hrroi t1, buffer ; Output resulting buffer
    psout%

    done: haltf% ; Exit to monitor
    jrst start ; Restartable program

    subttl Encode
    ; The encoder subroutine. Swap term with term+1 if conditions described
    ; at the top of this program are met. Since the terms are swapped, the
    ; resulting text can be fed back to this routine to decode as well.
    ; Q1 = term pointer T2 = actual character
    ; Q2 = term+1 pointer T1 = actual char (look ahead)
    encode: move q1, ptrbuf ; Fetch pointer to buffer
    move q2, ptrbuf ; to track term, term+1
    ibp q1 ; Increment to first char
    ldb t1, q1 ; Fetch first char from ptr
    movei t2, 2 ; Init term+1 by stepping ptr
    adjbp t2, q2 ; Advance term+1 ptr by T2 amt
    exch q2, t2 ; result left in T2 - move back
    ldb t1, q2 ; Get term+1 from Q2
    ldb t2, q1 ; Get term from Q1

    ; The term (Q1) and term+1 (Q2) pointers are initialized at this point
    ; to the 1st and second char in the string, respectively. Walk the input
    ; string buffer and swap if conditions are met using a loop. The look-ahead,
    ; Q2, signals when we are finished because it will be NULL. RDTTY% discards
    ; the \r\n on the input (but possibly not under DDT) and does not store
    ; it in the buffer.
    enc.1: cain t1, .CHNUL ; term+1 = NULL? If so, done
    jrst enc.3 ; We're done here

    ; Step over spaces
    spc: cain t2, .CHSPC ; term is space?
    jrst [ibp q1 ; Yes, get next terms
    ibp q2
    ldb t2, q1 ; To T2
    ldb t1, q2 ; and T1
    jrst spc] ; Skip spaces until not space

    ; Check T1, term+1, that it is in valid range
    caige t1, 101 ; >= A (0o101)?
    jrst enc.2 ; No, examine next chars
    caile t1, 172 ; <= z (0o172)?
    jrst enc.2 ; No, next
    caige t1, 141 ; >= a (0o141)? Then check
    jrst [caile t1, 132 ; also <= z (0o132)
    jrst enc.2 ; else out of range
    jrst enc.4 ] ; Still here? So T1 can swap

    ; Check T2, term, for valid range as well. Can I get a IF/THEN/ELSE/&& ?
    enc.4: caige t2, 101 ; >= A (0o101)?
    jrst enc.2 ; No, examine next chars
    caile t2, 172 ; <= z (0o172)?
    jrst enc.2 ; No, next
    caige t2, 141 ; >= a (0o141)? Then check
    jrst [caile t2, 132 ; also <= z (0o132)
    jrst enc.2 ; else out of range
    jrst enc.s ] ; Still here? T2 can swap also

    enc.s: exch t1, t2 ; Swap characters
    dpb t1, q2 ; Deposite byte to term+1 ptr
    dpb t2, q1 ; Write char to term pointer

    ; Look at next pair (term, term+1) of characters, below
    enc.2: movei t3, 2 ; Step by 2 for next terms
    adjbp t3, q1 ; Point to next char pairs
    exch q1, t3 ; We need it back in Q1
    movei t3, 2
    adjbp t3, q2 ; Jump T3 places in Q2 ptr
    exch q2, t3
    ldb t1, q2 ; Load next term+1 char
    ldb t2, q1 ; Load next term char
    jumpa enc.1 ; Loop for all chars
    enc.3: popj p, ; Return to caller

    lit ; Debugger to expand literals
    end start ; Assembler is done
    --
    PGP Key ID: 781C A3E2 C6ED 70A6 B356 7AF5 B510 542E D460 5CAE
    "The Internet should always be the Wild West!"
    --- Synchronet 3.22a-Linux NewsLink 1.2