Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -4,19 +4,19 @@ arg key p /*get key and text to be cyphered*/
|
|||
p=space(p,0) /*remove all blanks from text. */
|
||||
say 'Caesar cypher key:' key
|
||||
say ' plain text:' p
|
||||
y=caesar(p, key) ; say ' cyphered:' y
|
||||
z=caesar(y,-key) ; say ' uncyphered:' z
|
||||
if z\==p then say "plain text doesn't match uncyphered cyphered text."
|
||||
y=caesar(p, key) ; say ' cyphered:' y
|
||||
z=caesar(y,-key) ; say ' uncyphered:' z
|
||||
if z\==p then say "plain text doesn't match uncyphered cyphered text."
|
||||
exit /*stick a fork in it, we're done.*/
|
||||
/*──────────────────────────────────CAESAR subroutine───────────────────*/
|
||||
caesar: procedure; arg s,k; @='ABCDEFGHIJKLMNOPQRSTUVWXYZ'; L=length(@)
|
||||
ak=abs(k)
|
||||
if ak > length(@)-1 | k==0 | k=='' then call err k 'key is invalid'
|
||||
if ak>length(@)-1 | k==0 | k=='' then call err k 'key is invalid'
|
||||
_=verify(s,@) /*any illegal char specified ? */
|
||||
if _\==0 then call err 'unsupported character:' substr(s,_,1)
|
||||
if _\==0 then call err 'unsupported character:' substr(s,_,1)
|
||||
/*now that error checks are done:*/
|
||||
if k>0 then ky=k+1 /*either cypher it, or ... */
|
||||
else ky=27-ak /* decypher it. */
|
||||
if k>0 then ky=k+1 /*either cypher it, or ··· */
|
||||
else ky=27-ak /* decypher it. */
|
||||
return translate(s,substr(@||@,ky,L),@)
|
||||
/*──────────────────────────────────ERR subroutine──────────────────────*/
|
||||
err: say; say '***error!***'; say; say arg(1); say; exit 13
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
parse arg key p /*get key and text to be cyphered*/
|
||||
say 'Caesar cypher key:' key
|
||||
say ' plain text:' p
|
||||
y=caesar(p, key) ; say ' cyphered:' y
|
||||
z=caesar(y,-key) ; say ' uncyphered:' z
|
||||
if z\==p then say "plain text doesn't match uncyphered cyphered text."
|
||||
y=caesar(p, key) ; say ' cyphered:' y
|
||||
z=caesar(y,-key) ; say ' uncyphered:' z
|
||||
if z\==p then say "plain text doesn't match uncyphered cyphered text."
|
||||
exit /*stick a fork in it, we're done.*/
|
||||
/*──────────────────────────────────CAESAR subroutine───────────────────*/
|
||||
caesar: procedure; parse arg s,k; @='abcdefghijklmnopqrstuvwxyz'
|
||||
|
|
@ -13,11 +13,10 @@ caesar: procedure; parse arg s,k; @='abcdefghijklmnopqrstuvwxyz'
|
|||
/*last char is doubled, REXX quoted syntax rules.*/
|
||||
L=length(@)
|
||||
ak=abs(k)
|
||||
if ak>length(@)-1 | k==0 then call err k 'key is invalid'
|
||||
if ak>length(@)-1 | k==0 then call err k 'key is invalid'
|
||||
_=verify(s,@) /*any illegal char specified ? */
|
||||
if _\==0 then call err 'unsupported character:' substr(s,_,1)
|
||||
if k>0 then ky=k+1
|
||||
else ky=L+1-ak
|
||||
if _\==0 then call err 'unsupported character:' substr(s,_,1)
|
||||
if k>0 then ky=k+1
|
||||
else ky=L+1-ak
|
||||
return translate(s,substr(@||@,ky,L),@)
|
||||
/*──────────────────────────────────ERR subroutine──────────────────────*/
|
||||
err: say; say '***error!***'; say; say arg(1); say; exit 13
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue