Thursday, December 14, 2017

PC-2 Password Generator

So after the pyrrhic success with my PC-2 Enigma, I decided to repurpose a previous version for something else:  Password generator.

This version started out as an Enigma, but instead of needing an array to store the characters that I could us, I just used the ASCII character set 32-127.  Instead of looking up a value in an array, I could just do an "ASC" or "CHR$".  Much faster.

It had a big drawback, though.  Some of the characters in the table could not be input from the PC-2 keyboard.  So much for decrypting something.

But a password generator only needs to "encrypt".

1000 "V" clear: dim a$(1)*80: wait 0
1010 input "Start value:";r
1020 input a$(0)
1030 for i = 1 to len(a$(0))
1040 a= asc(mid$(a$(0),i,1))
1050 a=a-32+r
1060 if a > 95 LET a=a-96
1070 a=a+96/2
1080 if a > 95 LET a=a-96
1090 a=a+32
1095 :rem PC-2 chars not in standard ascii
1100 if a = 39 let a = 34
1110 if a = 91 let a = 123
1120 if a = 92 let a = 47
1130 if a = 93 let a = 125
1140 if a = 96 let a = 44
1150 if a = 127 let a = 32
1160 a$(1)=a$(1)+chr$ a
1170 r=r+1: if r >95 LET r=0
1180 cursor 0:print a$(1)
1190 next i
1200 wait: print a$(1)
1210 end

The only thing special was the 6 characters that the PC-2 uses that doesn't match up with the standard ASCII character set.  The PC-2 doesn't any single quotes (forward and back quotes).  It doesn't have "[" or "]" - instead it uses Yen and Square Root.  The "\" was some up-down square bracket that the PC-2 uses to denote an empty place in the string (sort of like a null).  And DEL was just like space.  So I convert those characters to something else.

This works much better and much faster.
So you enter something like "Tasty Cookies" and get "0>QSYa%RSPOL{" (start value of 12).
Given the same inputs, you will always get the same output.

I can say that the PC-2 is still useful today.

No comments: