| > | restart; |
| > | with(StringTools): |
| > | Alphabet:=cat(op(select( IsPrintable, [seq( convert([i],bytes), i=1..255)]))); |
| (1) |
| > | StringToList := proc(text::string)
global Alphabet; return( [seq( SearchText(text[i], Alphabet) ,i=1..length(text))] ); end: ListToString := proc( numlist :: list(posint)) global Alphabet; cat( seq( Alphabet[numlist[i]], i=1..nops(numlist) )); end: |
| > |
| > | StringToList("this is a message."); |
| (2) |
| > | Alphabet:="abcdefghijklmnopqrstuvwxyz"; |
| (3) |
| > | StringToList("hi"); |
| (4) |
| > | convert(1364,base,10); |
| (5) |
| > | convert([4,6,3,1],base,10,8); |
| (6) |
| > | 4+2*8+5*8^2+2*8^3; |
| (7) |
| > | 84+72*95; |
| (8) |
| > | 95*95; |
| (9) |
| > | convert([4,6,3,1],base,10,100); |
| (10) |
| > | Alphabet:=cat(op(select( IsPrintable, [seq( convert([i],bytes), i=1..255)]))); |
| (11) |
| > | nums:=StringToList("This is a message."); |
| (12) |
| > | nums2:=map(x->x-1,nums); |
| (13) |
| > | nums2:=[ seq( nums[i]-1, i=1..nops(nums))]; |
| (14) |
| > | convert(nums2,base,100,100^2); |
| (15) |
| > | p:=length(Alphabet); |
| (16) |
| > | convert(nums2,base,p,p^2); |
| (17) |
| > | StringToKgraph := proc (text::string, k::posint)
local p; global Alphabet; p:=length(Alphabet); convert( map(x->x-1,StringToList(text)), base, p, p^k); end: |
| > | StringToKgraph("This is a message.", 2); |
| (18) |
| > | StringToKgraph("This is a message.", 3); |
| (19) |
| > | KgraphToString := proc(numlist::list(nonnegint), k::posint)
local p; global Alphabet; p:=length(Alphabet); ListToString( map(x->x+1, convert( numlist, base, p^k, p))); end: |
| > | KgraphToString([6892, 7958, 6935, 83, 65, 6632, 7968, 6810, 1399], 2); |
| (20) |
| > | KgraphToString([6892, 7958, 6935, 83, 65, 6632, 7968, 6810, 1399], 5); |
| (21) |
| > | KgraphToString([6892, 7958, 6935, 83, 65, 6632, 7968, 6810, 1399], 3); |
| (22) |
| > |