Download code

Jump to: navigation, search

Back to Ciphersaber_(QBASIC)

Download for Windows: single file, zip

Download for UNIX: single file, zip, tar.gz, tar.bz2

csabre.bas

 1 REM The authors of this work have released all rights to it and placed it
 2 REM in the public domain under the Creative Commons CC0 1.0 waiver
 3 REM (http://creativecommons.org/publicdomain/zero/1.0/).
 4 REM 
 5 REM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 6 REM EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 7 REM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 8 REM IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 9 REM CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
10 REM TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
11 REM SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 REM 
13 REM Retrieved from: http://en.literateprograms.org/Ciphersaber_(QBASIC)?oldid=18707
14 
15 DIM fin$, f1%, fout$, f2%, ky$, q$, i%, j%, j&, s%(255) 
16 RANDOMIZE TIMER
17 
18 INPUT "Input File (+Encode, -Decode), Output File, Key: ", fin$, fout$,ky$ 
19 LET f1% = FREEFILE
20 OPEN MID$(fin$, 2) FOR BINARY AS #f1% 
21 LET f2% = FREEFILE
22 OPEN fout$ FOR BINARY AS #f2%
23 LET q$ = CHR$(RND * 256) + CHR$(RND * 256) + CHR$(RND * 256) + CHR$(RND * 256) + CHR$(RND * 256) + CHR$(RND * 256) + CHR$(RND * 256) + CHR$(RND * 256) + CHR$(RND * 256) + CHR$(RND * 256) 
24 IF LEFT$(fin$, 1) = "-" THEN GET #f1%, , q$ ELSE PUT #f2%, , q$ 
25 LET ky$ = ky$ + q$ 
26 FOR j% = 0 TO 255 
27    LET s%(j%) = j% 
28 NEXT 
29 FOR i% = 0 TO 255 
30    LET j% = (j% + s%(i%) + ASC(MID$(ky$, i% MOD LEN(ky$) + 1, 1))) MOD 256 
31    SWAP s%(j%), s%(i%) 
32 NEXT 
33 LET ky$ = " " 
34 FOR j& = 1 TO LOF(f1%) + (LEFT$(fin$, 1) = "-") * 10 
35    LET i% = (i% + s%(j& MOD 256)) MOD 256 
36    SWAP s%(i%), s%(j& MOD 256) 
37    GET #f1%, , ky$ 
38    LET ky$ = CHR$(ASC(ky$) XOR s%((s%(j& MOD 256) + s%(i%)) MOD 256)) 
39    PUT #f2%, , ky$ 
40 NEXT 
41 CLOSE #f1%, f2%
42 SYSTEM


hijacker
hijacker
hijacker
hijacker