#module
#deffunc strenc val, int
mref s, 24 : mref key, 1
if key >= 256 | (key < 0) : return // 指定可能なキーは0〜255
strlen len, s
repeat len
peek code, s, cnt
code -= key
if code = 0 : continue // 処理しない
if code < 0 : code = code + 256 // 下限値を超えるなら上限値に戻る
poke s, cnt, code
loop
return
#deffunc strdec val, int
mref s, 24 : mref key, 1
if key >= 256 | (key < 0) : return
strlen len, s
repeat len
peek code, s, cnt
code += key
if code = 256 : continue // 処理しない
if code >= 256 : code = code - 256 // 上限値を超えるなら下限値に戻る
poke s, cnt, code
loop
return
#global
randomize
rnd k, 200
s = "じゅげむじゅげむごこうのすりきれ"
strenc s, k // 暗号化
mes s
strdec s, k // 復号化
mes s
stop
|