43 lines
1019 B
Plaintext
43 lines
1019 B
Plaintext
CFStringRef local fn Encrypt( s as CFStringRef, key as int )
|
|
CFMutableStringRef s1 = fn MutableStringWithString(s)
|
|
for int i = 0 to len(s1) - 1
|
|
unichar c = ucc(s1,i)
|
|
select
|
|
case ( c >= _"A" && c <= _"Z")
|
|
c += key : if ( c > _"Z" ) then c -= 26
|
|
case ( c >= _"a" && c <= _"z" )
|
|
c += key : if ( c > _"z" ) then c -= 26
|
|
end select
|
|
mid(s1,i,1) = ucs(c)
|
|
next
|
|
end fn = s1
|
|
|
|
CFStringRef local fn Decrypt( s as CFStringRef, key as int )
|
|
CFMutableStringRef s1 = fn MutableStringWithString(s)
|
|
for int i = 0 to len(s1) - 1
|
|
unichar c = ucc(s1,i)
|
|
select
|
|
case ( c >= _"A" && c <= _"Z")
|
|
c -= key : if ( c < _"A" ) then c += 26
|
|
case ( c >= _"a" && c <= _"z" )
|
|
c -= key : if ( c < _"a" ) then c += 26
|
|
end select
|
|
mid(s1,i,1) = ucs(c)
|
|
next
|
|
end fn = s1
|
|
|
|
void local fn DoIt
|
|
CFStringRef s = @"The sun's not yellow, it's chicken"
|
|
print s
|
|
|
|
s = fn Encrypt( s, 6 )
|
|
print s
|
|
|
|
s = fn Decrypt( s, 6 )
|
|
print s
|
|
end fn
|
|
|
|
fn DoIt
|
|
|
|
HandleEvents
|